Jump to content

xsd minOccurs


workaholic06
 Share

Recommended Posts

I have the following element defined in my XSD file: <xs:element name="PartyAKA"> <xs:complexType> <xs:all> <xs:element name="LastOrBusinessName"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="1"/> <xs:maxLength value="35"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="FirstName" minOccurs="0"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="0"/> <xs:maxLength value="15"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="MiddleName"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:maxLength value="15"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="LastName2"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:maxLength value="20"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="NameSuffix"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:maxLength value="7"/> </xs:restriction> </xs:simpleType> </xs:element> </xs:all> </xs:complexType> </xs:element> When I validate my XML against this XSD, I get the message: The 'urn:myschema:FirstName' element is invalid - The value '' is invalid according to its datatype 'String' - The actual length is less than the MinLength value. I have tried adding the minOccurs="0", and minLength value="0" as shown in the sample above, but the validation error message still occurs. Can someone let me know if they've come across this, and if so, what the solution is? Thanks, Earl

Edited by workaholic06
Link to comment
Share on other sites

  • 4 months later...

I can't see the problem. You have...

<xs:element name="FirstName" minOccurs="0"><xs:simpleType><xs:restriction base="xs:string"><xs:minLength value="0"/><xs:maxLength value="15"/></xs:restriction></xs:simpleType></xs:element>

The example has...

<xs:element name="password">  <xs:simpleType>	<xs:restriction base="xs:string">	  <xs:minLength value="5"/>	  <xs:maxLength value="8"/>	</xs:restriction>  </xs:simpleType></xs:element>

From http://www.w3schools...hema_facets.asp

Edited by davej
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...