YouTip LogoYouTip

Schema Complex Indicators

Here's the translated English version with all code blocks and HTML tags preserved: ## XSD Indicators * * * Through indicators, we can control how elements are used in documents. * * * ## Indicators There are seven types of indicators: Order indicators: * All * Choice * Sequence Occurrence indicators: * maxOccurs * minOccurs Group indicators: * Group name * attributeGroup name * * * ## Order Indicators Order indicators are used to define the sequence of elements. ### All Indicator The indicator specifies that child elements can appear in any order, and each child element must appear only once: **Note:** When using the indicator, you can set to 0 or 1, but can only be set to 1 (we'll explain and later). ### Choice Indicator The indicator specifies that either one child element or another can appear (but not both): ### Sequence Indicator The indicator specifies that child elements must appear in a specific order: * * * ## Occurrence Indicators Occurrence indicators are used to define how often an element can appear. **Note:** For all "Order" and "Group" indicators (any, all, choice, sequence, group name, and group reference), the default values for both maxOccurs and minOccurs are 1. ### maxOccurs Indicator The indicator specifies the maximum number of times an element can appear: The example above shows that the child element "child_name" can appear at least once (since minOccurs defaults to 1) and at most 10 times within the "person" element. ### minOccurs Indicator The indicator specifies the minimum number of times an element can appear: The example above shows that the child element "child_name" can appear at least 0 times and at most 10 times within the "person" element. **Tip:** To allow unlimited occurrences of an element, use maxOccurs="unbounded": ### A Practical Example: An XML file named "Myfamily.xml": Hege Refsnes Cecilie Tove Refsnes Hege Stale Jim Borge Stale Refsnes This XML file contains a root element called "persons". Inside this root element, we've defined three "person" elements. Each "person" element must contain one "full_name" element and can contain up to five "child_name" elements. Here is the schema file "family.xsd": * * * ## Group Indicators Group indicators are used to define related sets of elements. ### Element Groups Element groups are defined with the group declaration: ... You must define an all, choice, or sequence element inside the group declaration. This example defines a group named "persongroup" that defines a set of elements that must appear in exact sequence: After defining a group, you can reference it in another definition: ### Attribute Groups Attribute groups are defined with the attributeGroup declaration: ... This example defines an attribute group named "personattrgroup": After defining an attribute group, you can reference it in another definition like this:
← Schema Complex AnySchema Complex Mixed β†’