| « | July 2026 | » | | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | |
| 公告 |
| 暂无公告... |
| Blog信息 |
|
blog名称: 日志总数:15 评论数量:4 留言数量:0 访问次数:46370 建立时间:2005年4月21日 |

| |
|
[收藏] -- 作者:teiki 文章收藏
xyin2005 发表于 2005/4/21 10:00:52 |
| 本文转载自W3CHINA.ORG讨论区(BBS.W3CHINA.ORG) 原文链接作者:teiki以下为原文:跟我学XML Schema(3):含子元素和孙元素的更复杂Schema文档
这次我们给出一个更加复杂一些的文档:
address.xml---------------<customer><name>Teiki</name><address><!-- address追加一个地址子元素 --><prefecture>Zhejiang</prefecture><city>Hangzhou</city><street>Xilu Road, No.121, 7F</street></address></customer>
为此,我们需要一个更加复杂一点的Schema文档:
address.xsd-----------------1: <?xml version="1.0"?>2: <xsd:schema xmlns:xsd="' target=_blank>http://www.w3.org/2001/XMLSchema">3:4: <xsd:element name="customer">5: <xsd:complexType>6: <xsd:sequence>7: <xsd:element name="name" type="xsd:string"/>8: <!-- 追加子元素address-->9: <xsd:element name="address">10: <xsd:complexType>11: <xsd:sequence>12: <xsd:element name="prefecture" type="xsd:string"/>13: <xsd:element name="city" type="xsd:string" />14: <xsd:element name="street" type="xsd:string" />15: </xsd:sequence>16: </xsd:complexType>17: </xsd:element>18: <!-- end -->19: </xsd:sequence>20: </xsd:complexType>21: </xsd:element>22:23:</xsd:schema>不过,我们还可以采用ref元素来重新编写这个Schema文档:address2.xsd----------------------1: <?xml version="1.0"?>2: <xsd:schema xmlns:xsd="' target=_blank>http://www.w3.org/2001/XMLSchema">3:4: <xsd:element name="customer">5: <xsd:complexType>6: <xsd:sequence>7: <xsd:element name="name" type="xsd:string"/>8: <xsd:element ref="address"/>9: </xsd:sequence>10: </xsd:complexType>11: </xsd:element>12:13: <xsd:element name="address">14: <xsd:complexType>15: <xsd:sequence>16: <xsd:element name="prefecture" type="xsd:string"/>17: <xsd:element name="city" type="xsd:string" />18: <xsd:element name="street" type="xsd:string" />19: </xsd:sequence>20: </xsd:complexType>21: </xsd:element>22:23: </xsd:schema>使用ref元素可以直接将其指向另一个模块,使文档更加具有可读性。<完>参与讨论本主题 |
|
|