2017-01-23 55 views
-1

XML文件的相應XSD和dtd代碼是什麼。無法聲明屬性。複雜類型和順序也有問題。給定XML文件的XSD代碼

<?xml version="1.0" encoding="UTF-8"?> 
<catalog xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" 
    xs:noNamespaceSchemaLocation="CatSchema.xsd"> 

    <product description="Cardigan Sweater" product_image="cardigan.jpg"> 

     <catalog_item gender="Men's"> 
      <item_number>QWZ5671</item_number> 
      <price>39.95</price> 
      <size description="Medium"> 
       <color_swatch image="red_cardigan.jpg">Red</color_swatch> 
       <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch> 
      </size> 
     </catalog_item> 

     <catalog_item gender="Women's"> 
      <item_number>RRX9856</item_number> 
      <price>42.50</price> 
      <size description="Medium"> 
       <color_swatch image="red_cardigan.jpg">Red</color_swatch> 
       <color_swatch image="navy_cardigan.jpg">Navy</color_swatch> 
       <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch> 
       <color_swatch image="black_cardigan.jpg">Black</color_swatch> 
      </size> 
     </catalog_item> 

    </product> 

</catalog> 
+4

你可以請粘貼您的XSD也在這裏。 –

+0

您確定還需要DTD嗎? XSD標準已經在很大程度上取代了DTD,當然新的發展趨向於支持XSD。 – Sprotty

回答

0

的XSD會是這個樣子

<?xml version="1.0" encoding="utf-8"?> 
<!-- Created with Liquid Studio 2017 - Developer Bundle Edition (Trial) 15.0.0.7089 (https://www.liquid-technologies.com) --> 
<schema xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema"> 
    <element name="catalog"> 
    <complexType> 
     <sequence> 
     <element minOccurs="0" name="product"> 
      <complexType> 
      <sequence> 
       <element minOccurs="0" maxOccurs="unbounded" name="catalog_item"> 
       <complexType> 
        <sequence> 
        <element minOccurs="0" name="item_number" type="string" /> 
        <element minOccurs="0" name="price" type="decimal" /> 
        <element minOccurs="0" name="size"> 
         <complexType> 
         <sequence> 
          <element minOccurs="0" maxOccurs="unbounded" name="color_swatch"> 
          <complexType> 
           <simpleContent> 
           <extension base="string"> 
            <attribute name="image" type="string" use="optional" /> 
           </extension> 
           </simpleContent> 
          </complexType> 
          </element> 
         </sequence> 
         <attribute name="description" type="string" use="optional" /> 
         </complexType> 
        </element> 
        </sequence> 
        <attribute name="gender" type="string" use="optional" /> 
       </complexType> 
       </element> 
      </sequence> 
      <attribute name="description" type="string" use="optional" /> 
      <attribute name="product_image" type="string" use="optional" /> 
      </complexType> 
     </element> 
     </sequence> 
    </complexType> 
    </element> 
</schema> 

enter image description here