XML文件的相应XSD和dtd代码是什么。在声明属性时遇到问题。复杂类型和序列也有问题。
<?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>
答案 0 :(得分: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>