如何在Linux上生成xsd模式?

时间:2019-01-08 10:25:54

标签: xml xslt xsd xml-parsing xmllint

对于此xml示例:

<note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don't forget me this weekend!</body>
</note>

创建了在线schema生成器:

<?xml version="1.0"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="note">
        <xs:complexType>
            <xs:sequence>
                <xs:element type="xs:string" name="to"/>
                <xs:element type="xs:string" name="from"/>
                <xs:element type="xs:string" name="heading"/>
                <xs:element type="xs:string" name="body"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

例如,如何使用xjc或Linux上可用的其他CLI工具来generate这个schema或类似或等效的schema? / p>

schema的验证方式为:

thufir@dur:~/jaxb$ 
thufir@dur:~/jaxb$ xmllint --schema note.xsd note.xml --noout
note.xml validates
thufir@dur:~/jaxb$ 

正在使用类似validates之类的东西对xmllint进行反运算。是的,我知道可以验证的无数(无限?)xsd个文件。只是根据在线schema生成器寻找东西。

0 个答案:

没有答案