Skip to Content
Real World XML
book

Real World XML

by Steven Holzner
January 2003
Beginner to intermediate content levelBeginner to intermediate
1200 pages
23h 42m
English
Peachpit Press
Content preview from Real World XML

Specifying Default Values for Elements

In addition to the minOccurs and maxOccurs attributes, you can use the <xsd:element> element's fixed and default attributes to indicate values that an element must have (you use one of these attributes, not both together). For example, setting fixed to 400 means that the element's value must always be 400. Setting the default value to 400, on the other hand, means that the default value for the element is 400, but if the element appears in the document, its actual value is the value it encloses.

For example, here I'm setting the value of an element named <maxTrials> to 100 and specifying that it must always be 100, using the fixed attribute in the <xsd:element> element:

 <xsd:element name="maxTrials" type="xsd:integer" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Inside XML

Inside XML

Steven Holzner
XML Hacks

XML Hacks

Michael Fitzgerald

Publisher Resources

ISBN: 0735712867Purchase book