2017-01-23 13 views
-1

Какой будет соответствующий XSD и dtd-код XML-файла. Возникли проблемы с объявлением атрибутов. Возникают проблемы с complextype и последовательность.XSD-код данного XML-файла

<?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