Use prefixes on the components you are defining and use the W3C XML Schema vocabulary without prefixes : attributeFormDefault « 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 » attributeFormDefault 
3. 85. 4. Use prefixes on the components you are defining and use the W3C XML Schema vocabulary without prefixes
File: Data.xml

<?xml version="1.0"?>
<library xmlns="http://java2s.com/ns/library">
  <book id="b0836217462" available="yes">
    <isbn>1</isbn>
    <title>Full-Time Job</title>
    <authors>
      <person id="i1">
        <name>A</name>
        <born>1999-11-26</born>
        <dead>2000-02-12</dead>
      </person>
    </authors>
    <characters>
      <person id="i2">
        <name>B</name>
        <born>1966-08-22</born>
        <qualification>bold, brash and tomboyish</qualification>
      </person>
      <person id="i3">
        <name>Snoopy</name>
        <born>1950-10-04</born>
        <qualification>extroverted beagle</qualification>
      </person>
    </characters>
  </book>
</library>

File: Schema.xsd
<?xml version="1.0"?>
<schema targetNamespace="http://java2s.com/ns/library"
  elementFormDefault="qualified" attributeFormDefault="unqualified"
  xmlns="http://www.w3.org/2001/XMLSchema"
  xmlns:lib="http://java2s.com/ns/library">
  <element name="library">
    <complexType>
      <sequence>
        <element name="book" type="lib:bookType" />
      </sequence>
    </complexType>
  </element>
  <element name="person">
    <complexType>
      <sequence>
        <element name="name" type="string" />
        <element name="born" type="date" />
        <element name="dead" type="date" minOccurs="0" />
        <element name="qualification" type="string"
          minOccurs="0" />
      </sequence>
      <attribute name="id" type="ID" use="required" />
    </complexType>
  </element>
  <complexType name="bookType">
    <sequence>
      <element name="isbn" type="string" />
      <element name="title" type="string" />
      <element name="authors">
        <complexType>
          <sequence>
            <element ref="lib:person" maxOccurs="unbounded" />
          </sequence>
        </complexType>
      </element>
      <element name="characters">
        <complexType>
          <sequence>
            <element ref="lib:person" maxOccurs="unbounded" />
          </sequence>
        </complexType>
      </element>
    </sequence>
    <attribute name="id" type="ID" use="required" />
    <attribute name="available" type="string" use="required" />
  </complexType>
</schema>
3. 85. attributeFormDefault
3. 85. 1. Set attributeFormDefault to qualified
3. 85. 2. Define prefixes in the schema for both our target namespace and for the W3C XML Schema namespace
3. 85. 3. Use the target namespace as the default namespace of the schema document
3. 85. 4. Use prefixes on the components you are defining and use the W3C XML Schema vocabulary without prefixes
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.