Total members 9951 | Gratitudes |It is currently Sat Feb 11, 2012 10:45 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Article
 Article subject: lesson5: XSD Complex elements
PostPosted: Thu Mar 05, 2009 11:36 pm 
Offline
Mastermind
User avatar

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

XSD Complex elements :

XSD Complex element contains other elements and attributes .


How to define complex elements:

For example the following XML file:
Code:
<student>
<name>Jozef samir</name>
<age>32</age>
</student>

<xs:element name="student">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="age" type="xs:long"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>


You define it by another way:
Code:
<xs:element name="student" type="studentType" >
  <xs:complexType name="studentType" >
    <xs:sequence>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="age" type="xs:long"/>
    </xs:sequence>
  </xs:complexType>


The difference between the two ways, in the first method you can only create one element of this complex type, but in the second way, you can define many elements using the same type.
For example :
Code:
<xs:element name="student" type="studentType" >
<xs:element name=" professor  " type="studentType" >


  <xs:complexType name="studentType" >
    <xs:sequence>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="age" type="xs:long"/>
    </xs:sequence>
  </xs:complexType>



Note: <xs:sequence> Tag means element should appear in same order in XML document.

2. XSD Complex Type extension:
You can extends the complex type and add more elements to it.
Code:
<xs:element name="student" type="studentType" >
  <xs:complexType name="studentType" >
    <xs:sequence>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="age" type="xs:long"/>
    </xs:sequence>
  </xs:complexType>

<xs:complexType name="moreinfo">
  <xs:complexContent>
    <xs:extension base="studentType">
      <xs:sequence>
        <xs:element name="address" type="xs:string"/>
        <xs:element name="city" type="xs:string"/>
        <xs:element name="country" type="xs:string"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>


_________________
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
 how to load the form elements depending on selection option  Scripting Language  saics  16
 Elements of a Java Program  Java  msi_333  2
 update an xml file with jaxb and accessing to its elements  Java  totomimi  5
 lesson9: XSD Complex Types Indicators  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