XSD元素的深入解析与应用
1. 全局声明与局部引用元素
在XSD中,元素可以全局声明并在局部引用。例如,对于 name.xsd 文件,以下是完整的模式定义:
<?xml version = "1.0" encoding = "UTF-8"?>
<xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
<xsd:element name = "name">
<xsd:complexType>
<xsd:sequence>
<xsd:element name = "first" type = "xsd:string"/>
<xsd:element name = "middle" type = "xsd:string" minOccurs = "0" maxOccurs = "unbounded"/>
<xsd:element name = "last" type = "xsd:string" maxOccurs = "unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
也可以将元素全局声明,然后在局部引用,如下所示:
<?xml version = "1.0" encoding = "UTF-8"
超级会员免费看
订阅专栏 解锁全文
29

被折叠的 条评论
为什么被折叠?



