XSD complains about "Several elements named" B ", with different types, appear in the model group."
I have the following XSD:
<xs:complexType name="typeBroken">
<xs:choice>
<xs:element name="B">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="FOO|BAR" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:sequence>
<xs:element name="A">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="5" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="B">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="3" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:choice>
</xs:complexType>
So, I would like "A" to do "B" in order to have a different check. Is it possible? For instance:
<test><B>FOO</B></test>
<test><A>HELLO</A><B>BAZ</B><test>
Both have to check. While:
<test><B>BAZ</B></test>
Should not be checked. However, I get from xsd:
cos-element-consistent: Error for type 'typeBroken'. Multiple elements with name 'B', with different types, appear in the model group.
0
Victor
a source
to share
1 answer
Do I understand your requirements correctly? Do you want to have <B>...</B>
and not necessarily <A>....</A>
before (but not necessary)?
How about this circuit?
<xs:complexType name="typeBroken">
<xs:sequence>
<xs:element name="A" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="5" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="B">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="FOO|BAR" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:choice>
</xs:complexType>
Define a sequence in which the first element <A>
is optional ( minOccurs="0"
) and the second is optional.
Does this solve your requirement?
Mark
0
a source to share