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!

XML Schema simpleType question

Status
Not open for further replies.

SanDiegolinus

Technical User
Jun 5, 2002
1
US
The following seems to be invalid wrt having a simpleType nested in a complexType...How do I specify the ssnType ?

<xs:complexType name=&quot;PersonType&quot;>
<xs:sequence>
<xs:element name=&quot;SSN&quot; type=&quot;SSNType&quot;>
<xs:simpleType name=&quot;SSNType&quot;>
<xs:restriction base=&quot;xs:string&quot;>
<xs:pattern value=&quot;[0-9]{9}&quot;/>
</xs:restriction>
</xs:simpleType>
</xs:element>
.....
 
The cleanest way to do this is to specify separately the simple type you are using, and then define the element as restriction or extension of that simple type:

<xs:complexType name=&quot;PersonType&quot;>
<xs:sequence>
<xs:element name=&quot;SSN&quot; type=&quot;SSNType&quot;>
<xs:restriction/extension> base=&quot;SSNType&quot;>
<!-- ... add something here -->
</xs:restriction/extension>
</xs:element>
.....
<xs:simpleType name=&quot;SSNType&quot;>
<xs:restriction base=&quot;xs:string&quot;>
<xs:pattern value=&quot;[0-9]{9}&quot;/>
</xs:restriction>
</xs:simpleType>

Something like this should do it. [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top