私はその構造を受け取るために計画しています:xsd-validateは正確な属性を持つ要素ですか?
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Document>
<property key="DocumentType" value="INV" />
<property key="InvInternalNumber" value="i-1651-84" />
<property key="OtherDynamicProperty" value="yes" />
</Document>
私は、ドキュメントタイプを識別し、ああ、ビジネスは請求書が「InvInternalNumber」プロパティを持たなければならないと言う
「INV.xsd」を検証するために行きます!
したがって、 xsdの検証が可能ですか?「InvInternalNumber」というプロパティがありますか?
更新 XSDはJaxbContextによって生成されています。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Document" type="Document"/>
<xs:complexType name="Document">
<xs:sequence>
<xs:element name="property" type="property" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="property">
<xs:sequence/>
<xs:attribute name="key" type="xs:string"/>
<xs:attribute name="value" type="xs:string"/>
</xs:complexType>
</xs:schema>
これはかなり基本的なXMLスキーマ検証ルールですか?スキーマファイルで "xs:attribute"検証ルールを試しましたか?この例を確認してください:http://www.w3schools.com/xml/schema_example.asp – EventHorizon
設定したINV.xsdスキーマも投稿できますか?あなたの心配は、構造の検証よりもむしろ書いているルールだと思う...だから、別のアプローチを使うかもしれない。 – potame
XMLはキーと値の順序付けられていないリストですか、または既知のキーリストの特定の順序を取ることができますか?このSOの質問への答えはおそらくあなたのために働くでしょうか? http://stackoverflow.com/questions/19543806/xml-schema-how-to-make-sure-one-element-exists-with-a-specific-attribute-value – EventHorizon