Articles → XSD → Indicators In XSD

Indicators In XSD





  1. Order indicator
    1. All
    2. Choice
    3. Sequence
  2. Occurrence indicator
    1. minOccurs
    2. maxOccurs
  3. Group indicator
    1. Element group
    2. Attribute group



All




<schema
	xmlns="http://www.w3.org/2001/XMLSchema">
	<element name="person">
		<complexType>
			<all>
				<element name="Section" type="string"/>
				<element name="name" type="string"/>
			</all>
		</complexType>
	</element>
</schema>




<person>
	<name>Karan</name>
	<Section>E</Section>
</person>




<person>
	<Section>E</Section>
	<name>Karan</name>
</person>



Choice




<schema
	xmlns="http://www.w3.org/2001/XMLSchema">
	<element name="person">
		<complexType>
			<choice>
				<element name="Section" type="string"/>
				<element name="name" type="string"/>
			</choice>
		</complexType>
	</element>
</schema>




<person>
	<name>Karan</name>
</person>




<person>
	<Section>E</Section>
</person>



Sequence





Minoccurs And Maxoccurs




<schema
	xmlns="http://www.w3.org/2001/XMLSchema">
	<element name="subject">
		<complexType>
			<sequence>
				<element name="name" type="string"/>
				<element name="books" type="string" minOccurs="1" maxOccurs="3"/>
			</sequence>
		</complexType>
	</element>
</schema>




<subject>
	<name>xml</name>
	<books>Book 1</books>
</subject>




<subject>
	<name>xml</name>
	<books>Book 1</books>
	<books>Book 2</books>
</subject>




<subject>
	<name>xml</name>
	<books>Book 1</books>
	<books>Book 2</books>
	<books>Book 3</books>
</subject>




  1. If you use minOccurs then it is required to use maxOccurs as well
  2. If you have not specified minOccurs then default value 1 is assigned to it.

Element Group






<x:group name=“group_name">
</x:group>




<x:schema
	xmlns:x="http://www.w3.org/2001/XMLSchema">
	<x:group name="personInfo">
		<x:sequence>
			<x:element name="name" type="x:string"/>
			<x:element name="age" type="x:int"/>
			<x:element name="Gender" type="x:string"/>
		</x:sequence>
	</x:group>
	<x:element name="person" type="personType"/>
	<x:complexType name="personType">
		<x:sequence>
			<x:group ref="personInfo"/>
			<x:element name="Address" type="x:string"/>
		</x:sequence>
	</x:complexType>
</x:schema>




<person>
	<name>Karan</name>
	<age>33</age>
	<Gender>M</Gender>
	<Address>Gurgaon</Address>
</person>



Attribute Group






<x:attributeGroup  name=“attr_group_name">
</x:attributeGroup>




<x:schema
	xmlns:x="http://www.w3.org/2001/XMLSchema">
	<x:attributeGroup name="personAttributes">
		<x:attribute name="name" type="x:string"/>
		<x:attribute name="age" type="x:integer"/>
	</x:attributeGroup>
	<x:element name="person">
		<x:complexType>
			<x:attributeGroup ref="personAttributes"/>
		</x:complexType>
	</x:element>
</x:schema>




<person name="Karan" age="33">
</person>



Posted By  -  Karan Gupta
 
Posted On  -  Friday, January 9, 2015

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250