<?xml version="1.0"?>
<catalog xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:x="urn:book">
<!-- START OF SCHEMA -->
<xsd:schema targetNamespace="urn:book">
<xsd:element name="book">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="author" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="genre" type="xsd:string"/>
<xsd:element name="price" type="xsd:float"/>
<xsd:element name="publish_date" type="xsd:date"/>
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<!-- END OF SCHEMA -->
<x:book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price currency="USD">44.95</price>
<publish_date>2000-10-01</publish_date>
<description lan="ENG">An in-depth look at creating applications with
XML.</description>
</x:book>
</catalog>
嗨,有人会介意在高价中宣布价格和描述元素内的属性吗?提前致谢
答案 0 :(得分:0)
<xsd:element name="description">
<xsd:attribute name="gender">
<xsd:simpleType>
<xsd:restriction base="xs:string">
<xsd:pattern value="male|female"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:element>