Narusegawa
asked on
XSD Restrictions
I'm trying to set some field lengths in an xsd but I get errors when using it to validate.
My XSD is as follows
I have 100's of fields to add and 60% are probably nvarchar120 in size. So this seems the best way to add this restriction to the xsd. However I can't see what's wrong with the above.
Help is appreciated.
For Reference the error I get is
"The 'http://www.w3.org/2001/XMLSchema:restriction' element is not supported in this context."
My XSD is as follows
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="ContactDetails" type="Contact"/>
<xs:complexType name="Contact">
<xs:sequence>
<xs:element name="Surname" type="xs:string"/>
<xs:element name="Firstname" type="xs:string"/>
<xs:sequence>
<xs:element name="Addresses">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="Address" type="Address"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Address">
<xs:sequence>
<xs:element name="Line1" type="xs:nvarchar120" minOccurs="1"/>
<xs:element name="Line2" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="nvarchar120">
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="120"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
I have 100's of fields to add and 60% are probably nvarchar120 in size. So this seems the best way to add this restriction to the xsd. However I can't see what's wrong with the above.
Help is appreciated.
For Reference the error I get is
"The 'http://www.w3.org/2001/XMLSchema:restriction' element is not supported in this context."
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.