Total members 9952 | Gratitudes |It is currently Sat Feb 11, 2012 2:04 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Article
 Article subject: lesson9: XSD Complex Types Indicators
PostPosted: Fri Mar 06, 2009 8:08 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2103
Location: Earth
Has thanked: 39 time
Have thanks: 57 time

XSD Complex Types Indicators :

There are seven indicators in XSD. There are three indicator groups.
1. Order indicators :
Define elements order inside your complex type.

Any indicator
Elements can appear in any order. And all must appears.
Code:
<xs:element name="student">
  <xs:complexType>
    <xs:all>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="age" type="xs:integer"/>
    </xs:all>
  </xs:complexType>
</xs:element>

Choice Indicator
Only one element of elements inside <choice> can appear.
Code:
<xs:element name="human">
  <xs:complexType>
    <xs:choice>
      <xs:element name="man" type="manType"/>
      <xs:element name="women" type="womenType"/>
    </xs:choice>
  </xs:complexType>
</xs:element>

Sequence Indicator
Elements should appear in the same order it was defined.
Code:
<xs:element name="student">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="age" type="xs:integer"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>


2. Occurrence Indicators
Define the number of times an element occurs. maxOccurs & minOccurs attributes are used to define occurrence .Both equal 1 by default.

maxOccurs Indicator:
Define the Maximum number of element occurs.
Code:
<xs:element name="department">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="Professor" type="xs:string" maxOccurs="unbounded"/>
      <xs:element name="Subject" type="xs:string" maxOccurs="50"
  />
    </xs:sequence>
  </xs:complexType>
</xs:element>


Note: you can set your limits to unlimited. You use maxOccurs="unbounded".

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<department>
<Professor>Jozef Philp</ Professor>
<Professor>Amr Ali</ Professor>
<Professor>Tom Philp</ Professor>
<Subject>Course1</Subject>
<Subject> Course2</Subject>
<Subject> Course3</Subject>
<Subject> Course4</Subject>
</department>

As you can above. The department has many professors and many subjects. Same cases to minOccurs attribute.

minOccurs Indicator:
Define the minimum number of element occurs.

3.Group Indicators
Allow you to define a set of related elements and attributes.

Elements groups:
For example look for the following XSD.
Code:
<xs:group name="studentgroup">
  <xs:sequence>
    <xs:element name="name" type="xs:string"/>
    <xs:element name="age" type="xs:integer"/>
    <xs:element name="gpa" type="xs:string"/>
  </xs:sequence>
</xs:group>



You can define your element group and reference to it from other definition.

Code:
<xs:group name="studentgroup">
  <xs:sequence>
    <xs:element name="name" type="xs:string"/>
    <xs:element name="age" type="xs:integer"/>
    <xs:element name="gpa" type="xs:string"/>
  </xs:sequence>
</xs:group>

<xs:element name="student" type="studentmoreType"/>
<xs:complexType name="studentmoreType">
  <xs:sequence>
    <xs:group ref="studentgroup"/>
    <xs:element name="Address" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

Attribute Groups:
Code:
<xs:attributeGroup name=" studentgroup">
  <xs:attribute name="name" type="xs:string"/>
  <xs:attribute name="age" type="xs:integer"/>
  <xs:attribute name="gpa" type="xs:string"/>
</xs:attributeGroup>


You can define your attribute group and reference to it from other definition.

Code:
<xs:attributeGroup name="studentgroup">
  <xs:attribute name="name" type="xs:string"/>
  <xs:attribute name="age" type="xs:integer"/>
  <xs:attribute name="gpa" type="xs:string"/>
</xs:attributeGroup>

<xs:element name="student">
  <xs:complexType>
    <xs:attributeGroup ref="studentgroup"/>
  </xs:complexType>
</xs:element>

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 lesson6: XSD Complex Empty Elements  XSD Tutorials  msi_333  1
 temperature transformer between different types  JavaScript examples  msi_333  0
 What are the types of jdbc drivers.?  C-C++  muralidhar  2
 lesson8: XSD Complex Type Mixed Content  XSD Tutorials  msi_333  0
 lesson7: XSD Complex Text-Only Elements  XSD Tutorials  msi_333  0

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Article | Next Article 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team