Forum Moderators: open

Message Too Old, No Replies

Why Does the Second Iteration of an xs:sequence Fail Schema Validation

Moving Right Along, We are now Validating Data...

         

cmarshall

4:10 pm on Mar 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay, I got all the namespace stuff straightened out (for now).

However, the actual instances being validated are failing, and I'm not sure why, as everything seems to be kosher.

Remember that, two days ago, I knew absolutely nada about this stuff, so I'm likely to be making silly mistakes.

Given this code in the .xsd:

.
.
.
<xs:element name="data_format">
<xs:complexType>
<xs:sequence>
<xs:element name="single_format">
<xs:complexType>
<xs:sequence>
<xs:element name="code" type="xs:string"/>
<xs:element name="description">
<xs:complexType>
<xs:sequence>
<xs:element name="english" type="xs:string"/>
<xs:element name="spanish" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="othertext">
<xs:complexType>
<xs:sequence>
<xs:element name="english" type="xs:string"/>
<xs:element name="spanish" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
.
.
.

And this code in the XML (Bolded Where the Error Flags):

.
.
.
<data_format>
<single_format>
<code>O</code>
<description>
<english>(Open) All are welcome.</english>
<spanish>(Abierta) Todos son bienvenidos.</spanish>
</description>
<othertext>
<english></english>
<spanish></spanish>
</othertext>
</single_format>
<!-- Okay, time for the second iteration. Let's fail validation! WHEE! -->

<single_format>

<code>D</code>
<description>
<english>(Discussion) This meeting invites participation by all attendees.</english>
<spanish>(Discusi?n) Esta reuni?n invita la participaci?n de todos los asistentes.</spanish>
</description>
<othertext>
<english></english>
<spanish></spanish>
</othertext>
</single_format>
.
.
.
</data_format>
.
.
.

The error occurs at the second iteration of the sequence. This is a list that can have an arbitrary length.

The exact validation failure message is:

"cvc-complex-type.2.4.d: Invalid content was found starting with element 'single_format'. No child element is expected at this point."

According to all literature on the subject, any element within an <xs:sequence> element can repeat from 0 to n times, yet this is not being allowed here.

This is an excerpt from a more complex schema, and several other <xs:complexType> elements are declared prior to this with no problem. This is the first with an arbitrary repeating number of children.

Any ideas?

cmarshall

4:25 pm on Mar 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Never mind. I got it.

Apparently, you need to specify 'maxOccurs="unbounded"'.

Duh.