Schema約束XML檔案的執行個體

來源:互聯網
上載者:User

IT程式員開發必備-各類資源下載清單,史上最全IT資源,個人收藏總結。 shiporder_1.xsd檔案:

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

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

      targetNamespace="http://www.itstar.cn/shiporder_1"

   elementFormDefault="qualified">

  <xs:element name="shiporder">

    <xs:complexType>

      <xs:sequence>

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

        <xs:element name="shipto">

          <xs:complexType>

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

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

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

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

            </xs:sequence>

           </xs:complexType>

        </xs:element>

        <xs:element name="item" maxOccurs="unbounded">

          <xs:complexType>

            <xs:sequence>

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

              <xs:element name="note" type="xs:string" minOccurs="0" />

              <xs:element name="quantity" type="xs:positiveInteger"></xs:element>

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

            </xs:sequence>

          </xs:complexType>

        </xs:element>

      </xs:sequence>

      <xs:attribute name="orderid" type="xs:string" use="required" />

    </xs:complexType>

  </xs:element>

</xs:schema>

shiporder_2.xsd檔案:(不知道為什麼此種方式不能加入targetNamespace屬性)

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

<xh:schema xmlns:xh="http://www.w3.org/2001/XMLSchema"

     elementFormDefault="qualified">

<!-- 簡易元素的定義 -->

  <xh:element name="orderperson" type="xh:string" />

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

  <xh:element name="address" type="xh:string" />

  <xh:element name="city" type="xh:string" />

  <xh:element name="country" type="xh:string" />

  <xh:element name="title" type="xh:string" />

  <xh:element name="note" type="xh:string" />

  <xh:element name="quantity" type="xh:positiveInteger" />

  <xh:element name="price" type="xh:decimal" />

<!-- 屬性的定義 -->

  <xh:attribute name="orderid" type="xh:string" />

<!-- 複合元素的定義 -->

  <xh:element name="shipto">

    <xh:complexType>

      <xh:sequence>

        <xh:element ref="name" />

        <xh:element ref="address" />

        <xh:element ref="city" />

        <xh:element ref="country" />

      </xh:sequence>

     </xh:complexType>

   </xh:element>


  <xh:element name="item">

    <xh:complexType>

      <xh:sequence>

        <xh:element ref="title" />

        <xh:element ref="note" minOccurs="0" />

        <xh:element ref="quantity" />

        <xh:element ref="price" />

       </xh:sequence>

     </xh:complexType>

  </xh:element>


  <xh:element name="shiporder">

    

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.