Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSD maxOccurs="unbounded"

Tags:

xml

xsd

I have generated an XSD file from an XML snippet using xsd.exe /out

What its done is created maxOccurs="unbounded" properties for certain elements.

If I only want the element to appear once, and not be a collection do I set the maxOccurs like this?

maxOccurs="1"

like image 547
JL. Avatar asked Jul 22 '09 14:07

JL.


3 Answers

Yes. Of course, keep in mind that maxOccurs is really maximum occurances - there can still be zero. If you want there to always be one, you'll need minOccurs="1" as well.

like image 147
Nick Bastin Avatar answered Oct 14 '22 05:10

Nick Bastin


Yes, that's how it's done.

maxOccurs limits the maximum number of repetitions of a given element that can appear.

Similarly, minOccurs limits the minimum number of repetitions.

They're called occurrence indicators. You can read more about them at W3Schools.

like image 37
Welbog Avatar answered Oct 14 '22 05:10

Welbog


http://www.w3schools.com/schema/schema_example.asp says that: "The default value for both maxOccurs and minOccurs is 1!"

like image 44
Erik Svensson Avatar answered Oct 14 '22 07:10

Erik Svensson