Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Schema Based Problems

Status
Not open for further replies.

jaybytez

Programmer
Jan 8, 2003
65
US
I am a rookie to schemas and am having some validation type issues with a schema. Could someone tell me what it looks like I am doing wrong within this schema? Thanks.

<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<xs:schema xmlns:xsd=&quot; <xs:element name=&quot;subscriberID&quot; type=&quot;SubscriberIDType&quot;/>
<xs:element name=&quot;queryrequest&quot; type=&quot;QueryRequestType&quot;/>
<xs:element name=&quot;queryresponse&quot; type=&quot;QueryResponseType&quot;/>
<xs:element name=&quot;provision&quot; type=&quot;ProvisionType&quot;/>
<xs:element name=&quot;inquire&quot; type=&quot;InquireType&quot;/>
<xs:element name=&quot;response&quot; type=&quot;ResponseType&quot;/>
<xs:element name=&quot;requeue&quot; type=&quot;RequeueType&quot;/>
<xs:complexType name=&quot;SubscriberIDType&quot;>
<xs:attribute name=&quot;idtype&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
<xs:attribute name=&quot;idvalue&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
</xs:complexType>
<xs:complexType name=&quot;QueryRequestType&quot;>
<xs:all>
<xs:element name=&quot;criteria&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;>
<xs:attribute name=&quot;name&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
<xs:attribute name=&quot;value&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
</xs:element>
<xs:element name=&quot;qualifier&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;>
<xs:attribute name=&quot;name&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
<xs:attribute name=&quot;value&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
</xs:element>
</xs:all>
</xs:complexType>
<xs:complexType name=&quot;QueryResponseType&quot;>
<xs:element name=&quot;queryresult&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;>
<xs:complexType>
<xs:element name=&quot;queryfield&quot; maxOccurs=&quot;unbounded&quot;>
<xs:attribute name=&quot;name&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
<xs:attribute name=&quot;value&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
</xs:element>
<xs:attribute name=&quot;subtype&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
<xs:attribute name=&quot;type&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
</xs:complexType>
</xs:element>
</xs:complexType>
<xs:complexType name=&quot;RequeueType&quot;>
<xs:all>
<xs:element name=&quot;criteria&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;>
<xs:attribute name=&quot;name&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
<xs:attribute name=&quot;value&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
</xs:element>
<xs:element name=&quot;result&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;>
<xs:attribute name=&quot;name&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
<xs:attribute name=&quot;value&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
</xs:element>
</xs:all>
<xs:attribute name=&quot;type&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
</xs:complexType>
<xs:complexType name=&quot;ProvisionType&quot;>
<xs:all>
<xs:element name=&quot;action&quot; type=&quot;xs:string&quot;/>
<xs:element name=&quot;field&quot; maxOccurs=&quot;unbounded&quot;>
<xs:attribute name=&quot;name&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
<xs:attribute name=&quot;value&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
</xs:element>
</xs:all>
</xs:complexType>
<xs:complexType name=&quot;InquireType&quot;>
<xs:all>
<xs:element name=&quot;action&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot;/>
<xs:element name=&quot;field&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;>
<xs:attribute name=&quot;name&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
<xs:attribute name=&quot;value&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
</xs:element>
</xs:all>
</xs:complexType>
<xs:complexType name=&quot;ResponseType&quot;>
<xs:element name=&quot;field&quot; maxOccurs=&quot;unbounded&quot;>
<xs:attribute name=&quot;name&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
<xs:attribute name=&quot;value&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
</xs:element>
</xs:complexType>
</xs:schema>
 
Firstly I would always be explicit with the minOccurs it can solve many spurious errors.

Secondly, you have the wrong xmlns - it should be:

Code:
<xs:schema xmlns:xs=&quot;[URL unfurl="true"]http://www.w3.org/2001/XMLSchema&quot;[/URL] elementFormDefault=&quot;qualified&quot; attributeFormDefault=&quot;unqualified&quot;>

Thirdly,

In all cases of an XML element that you have attributs you MUST wrap the attributes within an <xs:complexType> tag e.g.

Code:
<xs:element name=&quot;field&quot; maxOccurs=&quot;unbounded&quot;>
      <xs:attribute name=&quot;name&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
      <xs:attribute name=&quot;value&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
    </xs:element>

Should be:

Code:
<xs:element name=&quot;field&quot; maxOccurs=&quot;unbounded&quot;>
  <xs:complexType>
      <xs:attribute name=&quot;name&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
      <xs:attribute name=&quot;value&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/>
    </xs:complexType>
</xs:element>

Hope this helps,

James :) James Culshaw
james@miniaturereview.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top