How do I restrict the length of character in XML Schema?



I have not dabbled in xml much and have been trying to google my way out of a little of trying to restrict the maximum of characters a user is allowed to enter into a box.


Here is my current code:



<xs:complexType name="reason">
<xs:attribute name="reason">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value = "75"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>


The field name on our database is called reason and I have defined the character length to nvarchar(75).


I am also trying to use same name as the attribute name on the xml.


What is happening currently is that when a user enters more than 75 characters, an error message ensues.


This tells me that the restrictions on my xsd file is not working correctly.


Any ideas what I am missing?


No comments:

Post a Comment