0
私が使用しているXSDを以下で見つけてください。存在することがSTYPE1とSTYPE2:私は要素の少なくとも1つまたは両方をしたいです。XSDバリデーション - どちらか一方または両方
エラーを得:要素「要素は」無効な見当違いである、またはあまりにも頻繁に発生します。ここで
は私のxsdです:ここでは
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="table">
<xs:complexType>
<xs:sequence>
<xs:element name="rows">
<xs:complexType>
<xs:sequence>
<xs:element name="row" maxOccurs="unbounded" minOccurs="0">
<xs:complexType mixed="true">
<xs:element name="SNO" type="xs:string"/> \t \t
<xs:choice minOccurs="1" maxOccurs="2">
<xs:element name="STYPE1" type="Type1"/> \t \t \t \t \t \t
<xs:element name="STYPE2" type="Type2"/> \t
<xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- Start with either A or B followed by 8 characters -->
<xs:simpleType name="Type1">
<xs:restriction base="xs:string">
<xs:pattern value="(A|B)([a-zA-Z0-9])*"/>
\t <xs:length value="9"/>
</xs:restriction>
</xs:simpleType>
<!-- Start with either C or D followed by 6 characters -->
<xs:simpleType name="Type2">
<xs:restriction base="xs:string">
<xs:pattern value="(C|D)([a-zA-Z0-9])*"/>
\t <xs:length value="7"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
は私のxmlファイルです:
<root>
<table>
<rows>
<row>
<SNO>1</SNO>
<STYPE1>A12345678</STYPE1>
<STYPE2>C654321</STYPE2>
</row> \t
\t \t <row>
<SNO>2</SNO>
<STYPE1>B12345678</STYPE1>
<STYPE2>D654321</STYPE2>
</row>
</rows>
</table>
</root>
任意の助けをいただければ幸いです。 SNO要素宣言およびxsの周りに欠落しているシーケンスの要素:選択要素XSがあるので
感謝。実際、XML要素(SNO、STYPE1、STYPE2)は任意の順序で指定できます。 xs:シーケンスを追加すると、これはもはや不可能になります。しかし、xs:sequenceがなければ、xs:choiceは機能しません。任意のアイデアはどのようにこの問題を解決するには? – Original16