日期:2014-05-18  浏览次数:20635 次

XML schema 这几句不懂
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
targetNamespace="http://www.sunxin.org/book"
xmlns="http://www.sunxin.org/book">
<xs:element name="book" type="bookType"/>
<xs:complexType name="bookType">
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
</xs:sequence>
<xs:attribute name="isbn" type="xs:token"/>
</xs:complexType>
</xs:schema>




请问,上面的schema文档定义了几个元素,嵌套情况是怎么样的?不会complexType定义了一个元素吧

------解决方案--------------------
http://blog.csdn.net/xiandaliu/article/details/464143
------解决方案--------------------
<xs:complexType name="bookType">,name="bookType"
相当于声明一个类。类名为bookType

<xs:element name="book" type="bookType"/>
book 相当于一个指向bookType类型的对象。

complexType 是一种类型,一种比string更复杂的类型。
complexType 就好比定义一个实体类。
------解决方案--------------------
定义这个类之后,可以多处使用,而不用每个地方都重新定义。

当然,你这个里面不存在重复使用的情况,可以不用这种方式。