Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I Have the following XSD
HTML
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="address"><xs:complextype><xs:sequence><xs:element name="name" type="xs:string" /><xs:element name="street" type="xs:string" /><xs:element name="city" type="xs:string" /><xs:element name="country" type="xs:string" /></xs:sequence></xs:complextype></xs:element></xs:schema>

using this xsd i am validation my xml. But how I can check that the name should not cross 30 characters. For this wat what validations I have to write in my xsd code

Kindly help in this.

Regards,
Posted
Updated 1-Jun-12 1:18am
v2

1 solution

Use a restriction:

HTML
<xs:element name="name">
  <xs:simpletype>
    <xs:restriction base="xs:string">
      <xs:maxlength value="30" />
    </xs:restriction>
  </xs:simpletype>
</xs:element>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900