对于此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
生成器寻找东西。