Click here to Skip to main content
12,067,928 members (30,365 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET XML
hello friends

i have one schema
which contain element like

<xs:element minOccurs="0" name="employee" nillable="true" maxOccurs="2" type="xs:string"/>

I have one xml file with no element named "employee". As per xml schema minOccurs is Zero(0), so validation should not fail.

But if there isn't any employee element, I get error in validate.

How can i solve it


please help
thanks
Posted 30-Jul-12 8:31am
PKriyshnA1.7K
Edited 31-Jul-12 5:08am
Malli_S27.8K
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

hi PKriyshnA.
have you tried this:

<xs:element name="employee">
   <xs:complexType>
     <xs:all minOccurs="0">
       <xs:element name="FirstN" type="xs:string"/>
       <xs:element name="LastN" type="xs:string"/>
     </xs:all>
   </xs:complexType>
 </xs:element>

The example above indicates that the "firstname" and the "lastname" elements can appear in any order and each element CAN appear zero or one time!
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160208.1 | Last Updated 31 Jul 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100