03XML Schema Definition

1. XML Schema Definition


1. XML Schema Definition

XML Schema(XML Schema Definition,XSD)用于描述 XML 文档的结构

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">

    <xs:element name="BOOKS">

        <xs:annotation>

            <xs:documentation>Comment describing your root element</xs:documentation>

        </xs:annotation>

        <xs:complexType>

            <xs:sequence>

                <xs:element ref="BOOK" minOccurs="1" maxOccurs="unbounded"/>

            </xs:sequence>

        </xs:complexType>

    </xs:element>

    <xs:element name="BOOK">

        <xs:complexType>

            <xs:sequence>

                <xs:element name="TITLE" type="xs:string"/>

                <xs:element name="AUTHOR" type="xs:string"/>

                <xs:element name="PAGE" type="xs:int"/>

                <xs:choice>

                    <xs:element name="PRICE" type="xs:decimal"/>

                    <xs:element name="DISCOUNT" type="xs:decimal"/>

                </xs:choice>

            </xs:sequence>

        </xs:complexType>

    </xs:element>

</xs:schema>

 

<?xml version="1.0" encoding="UTF-8"?>

<BOOKS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BOOKS.xsd">

    <BOOK>

        <TITLE>XML</TITLE>

        <AUTHOR>JIM</AUTHOR>

        <PAGE>30</PAGE>

        <PRICE>20</PRICE>

    </BOOK>

    <BOOK>

        <TITLE>XML</TITLE>

        <AUTHOR>JIM</AUTHOR>

        <PAGE>30</PAGE>

        <DISCOUNT>10</DISCOUNT>

    </BOOK>

    <BOOK>

        <TITLE>XML</TITLE>

        <AUTHOR>JIM</AUTHOR>

        <PAGE>30</PAGE>

        <PRICE>20</PRICE>

    </BOOK>

</BOOKS>

上一篇:GYM101673J(模拟)


下一篇:WPF开发ArcGis系统时的异常信息: ArcGIS product not specified. You must first bind to an ArcGIS version prior to using any ArcGIS components.