xml - xsd - sequence vs choice -



xml - xsd - sequence vs choice -

i confused xml schema sequence according w3schools.com, the sequence element specifies kid elementsmust appearin sequence. each kid element can occur from0to number of times. if each element must appear, how can occur 0 times? wouldn't break must appear rule?

and thing, difference between

<xs:choice minoccurs="0" maxoccurs="unbounded"> <xs:element name="choicea" type="xs:string" > <xs:element name="choiceb" type="xs:string" /> </xs:choice>

and this:

<xs:sequence minoccurs="0" maxoccurs="unbounded"> <xs:element name="choicea" type="xs:string" > <xs:element name="choiceb" type="xs:string" /> </xs:sequence>

can't set number of each element both of these cases? there difference @ all?

the elements within sequence must appear in order specified in schema. if element defined minoccurs="0" not have appear.

here similar illustration 1 1 w3schools.com tutorial. have added minoccurs="0" firstname element.

<xs:element name="employee"> <xs:complextype> <xs:sequence> <xs:element name="firstname" type="xs:string" minoccurs="0"/> <xs:element name="lastname" type="xs:string"/> </xs:sequence> </xs:complextype> </xs:element>

in case valid xml elements based on definition

<employee> <firstname>john</firstname> <lastname>smith</lastname> </employee>

or remove firstname element because has minoccurs="0"

<employee> <lastname>smith</lastname> </employee>

you cannot mix order of elements. invalid.

<employee> <lastname>smith</lastname> <firstname>john</firstname> </employee>

as difference between selection , sequence. selection element allows 1 of elements appear. selection have choicea or choiceb not both. whereas way sequence defined each sequence element going have both choicea , choiceb.

xml xsd

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -