Referencing Already Defined Elements : Reference « XML Schema « XML Tutorial

XML Tutorial
1. Introduction
2. Namespace
3. XML Schema
4. XPath
5. XSLT stylesheet
Java
XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
XML Tutorial » XML Schema » Reference 
3. 95. 1. Referencing Already Defined Elements
You can only reference element declarations within sequences, sets of choices, unordered groups, and named group definitions.
Each reference may contain distinct values for minOccurs and maxOccurs.
 

File: Data.xml
<?xml version="1.0"?>  
<library> 
  <book id="b0836217462" available="true"
    <isbn>1111111111</isbn> 
    <title lang="en">Java</title> 
    <author id="CMS"
      <name>name</name> 
      <born>1998-11-26</born> 
      <dead>2000-02-12</dead> 
    </author> 
    <character id="PP"
      <name>Swing</name> 
      <born>1996-08-22</born> 
      <qualification>Yes</qualification> 
    </character> 
    <character id="Web"
      <name>JSP</name> 
      <born>1997-10-04</born> 
      <qualification>No</qualification> 
    </character> 
  </book> 
</library> 

File: Schema.xsd  
<?xml version="1.0"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  <xs:element name="name" type="xs:string"/> 
  <xs:element name="qualification" type="xs:string"/> 
  <xs:element name="born" type="xs:date"/> 
  <xs:element name="dead" type="xs:date"/> 
  <xs:element name="isbn" type="xs:string"/> 
  <xs:attribute name="id" type="xs:ID"/> 
  <xs:attribute name="available" type="xs:boolean"/> 
  <xs:attribute name="lang" type="xs:language"/> 
  <xs:element name="title"
    <xs:complexType> 
      <xs:simpleContent> 
        <xs:extension base="xs:string"
          <xs:attribute ref="lang"/> 
        </xs:extension> 
      </xs:simpleContent> 
    </xs:complexType> 
  </xs:element> 
  <xs:element name="library"
    <xs:complexType> 
      <xs:sequence> 
        <xs:element ref="book" maxOccurs="unbounded"/> 
      </xs:sequence> 
    </xs:complexType> 
  </xs:element> 
  <xs:element name="author"
    <xs:complexType> 
      <xs:sequence> 
        <xs:element ref="name"/> 
        <xs:element ref="born"/> 
        <xs:element ref="dead" minOccurs="0"/> 
      </xs:sequence> 
      <xs:attribute ref="id"/> 
    </xs:complexType> 
  </xs:element> 
  <xs:element name="book"
    <xs:complexType> 
      <xs:sequence> 
        <xs:element ref="isbn"/> 
        <xs:element ref="title"/> 
        <xs:element ref="author" minOccurs="0" maxOccurs="unbounded"/>  
        <xs:element ref="character" minOccurs="0" 
          maxOccurs="unbounded"/> 
      </xs:sequence> 
      <xs:attribute ref="id"/> 
      <xs:attribute ref="available"/> 
    </xs:complexType> 
  </xs:element> 
  <xs:element name="character"
    <xs:complexType> 
      <xs:sequence> 
        <xs:element ref="name"/> 
        <xs:element ref="born"/> 
        <xs:element ref="qualification"/> 
      </xs:sequence> 
      <xs:attribute ref="id"/> 
    </xs:complexType> 
  </xs:element> 
</xs:schema>
3. 95. Reference
3. 95. 1. Referencing Already Defined Elements
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.