c# - XML Schema with repeating elements -


i trying deserialise following xml:

<queries>     <query name='abc'>         <statement>select * table1</statement>         <label row='1' name='id'/>         <label row='2' name='name'/>     </query>     <query name='another'>         <statement>select * table2</statement>         <label row='1' name='mytabid'/>         <label row='2' name='mytabname'/>     </query> </queries> 

to validate schema using:

<xs:complextype name="queries">   <xs:sequence>     <xs:element name="query" type="query"/>   </xs:sequence> </xs:complextype>  <xs:complextype name="query">   <xs:sequence>     <xs:element name="statement" minoccurs="1" maxoccurs="1"/>     <xs:element name="label">       <xs:complextype>         <xs:attribute name="row" type="xs:int" use="required"/>         <xs:attribute name="name" type="xs:string" use="required"/>       </xs:complextype>     </xs:element>   </xs:sequence>   <xs:attribute name="name" type="xs:string"/> </xs:complextype> 

validation failing message:

not valid. error - line 7, 48: org.xml.sax.saxparseexception; linenumber: 7; columnnumber: 48; cvc-complex-type.2.4.d: invalid content found starting element 'label'. no child element expected @ point. error - line 9, 31: org.xml.sax.saxparseexception; linenumber: 9; columnnumber: 31; cvc-complex-type.2.4.d: invalid content found starting element 'query'. no child element expected @ point.

what missing please? need specify different tag sequence? want enforce @ least 1 query existing.

thank in advanced :)

the error message complains definition

<xs:element name="label"> 

and use

<label row='1' name='id'/> <label row='2' name='name'/> 

the default values (w3) minoccurs , maxoccurs 1, can use 1 label there. need change if use more labels. use unbounded arbitrary amount.

also note similar maxoccurs adjustment (unbounded or greater 1) needed query (as commented @kjhughes)


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -