Local and Global Declarations : Global Local « 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 » Global Local 
3. 96. 4. Local and Global Declarations
<?xml version="1.0" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <xsd:element name="animal" type="endType" />

  <xsd:element name="name" type="xsd:string" />

  <xsd:complexType name="endType">
    <xsd:sequence>
      <xsd:element name="animal">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element ref="name" minOccurs="0" />
            <xsd:element name="source" type="xsd:string" />
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="habitatType">
    <xsd:sequence>
      <xsd:element name="river">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element ref="name" minOccurs="1" maxOccurs="unbounded" />
            <xsd:element name="source" type="xsd:string" />
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

Globally components appear on the first level below the xsd:schema element.
You can have two locally declared elements with the same name but different definitions.
Their context keeps them distinct. 
Global element declarations must have unique names. 
You must reference a global element in order to have it appear in a corresponding XML document.
When you define a complex type, you can either reference existing globally declared elements, or you can declare and define newelements on the spot. 
Locally declared elements are limited to the complex type definition in which they are declared.
Locally declared elements may not be used elsewhere in the schema.
3. 96. Global Local
3. 96. 1. Global type versus Local type
3. 96. 2. An XML Schema Using Inline (or Local) Declarations
3. 96. 3. XML Schema Structures
3. 96. 4. Local and Global Declarations
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.