import schema and elementFormDefault : import « XML Schema « XML

XML
1. CSS Style
2. SVG
3. XML Schema
4. XQuery
5. XSLT stylesheet
Java
XML Tutorial
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 » XML Schema » import 
import schema and elementFormDefault


File: Data.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="Books.xsl"?>
<Books xmlns="http://www.java2java.com"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation=
                          "http://www.java2java.com
                           Books.xsd">
        <Book xmlns="http://www.java.org">
                <Title>title1</Title>
                <Author>author1</Author>
                <Date>1998</Date>
                <ISBN>1-11111-111-1</ISBN>
                <Publisher>publisher1</Publisher>
        </Book>
        <Book xmlns="http://www.java2s.org">
                <Title>title2</Title>
                <Author>author2</Author>
                <Date>1977</Date>
                <ISBN>2-222-22222-2</ISBN>
                <Publisher>publisher2</Publisher>
        </Book>
</Books>


File: Books.xsd

<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://www.java2java.com"
        xmlns:bk="http://www.demo2s.com"
        elementFormDefault="qualified">

    <import namespace="http://www.demo2s.com"
            schemaLocation="Book.xsd"/>

    <element name="Books">
        <complexType>
            <sequence>
                <element ref="bk:Book" maxOccurs="unbounded"/>
            </sequence>
        </complexType>
    </element>
</schema>

File: Book.xsd

<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.demo2s.com"
            elementFormDefault="qualified">
    <element name="Book">
        <complexType>
            <sequence>
                <element name="Title" type="string"/>
                <element name="Author" type="string"/>
                <element name="Date" type="gYear"/>
                <element name="ISBN" type="string"/>
                <element name="Publisher" type="string"/>
            </sequence>
        </complexType>
    </element>
</schema>

 
Related examples in the same category
1. import another XML schema
2. import with namespace
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.