我是XML架构和XMPP消息协议的初学者。有没有明确的方法来理解下面的XML模式。每个标签的含义是什么以及有多少类型的标签 - 指定的阅读和编写方式是什么:
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema
xmlns:xs='http://www.w3.org/2001/XMLSchema'
targetNamespace='http://jabber.org/protocol/address'
xmlns='http://jabber.org/protocol/address'
elementFormDefault='qualified'>
<xs:annotation>
<xs:documentation>
The protocol documented by this schema is defined in
XEP-0033: http://www.xmpp.org/extensions/xep-0033.html
</xs:documentation>
</xs:annotation>
<xs:element name='address'>
<xs:complexType>
<xs:simpleContent>
<xs:extension base='empty'>
<xs:simpleType>
<xs:restriction base='xs:NCName'>
<xs:enumeration value='bcc'/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name='uri' use='optional' type='xs:string'/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name='empty'>
<xs:restriction base='xs:string'>
<xs:enumeration value=''/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
答案 0 :(得分:0)
XSD是一种复杂的语言,并且无法在几个段落中给出充分的解释。阅读W3C XML Schema Primer(XML Schema Part 0)可能是一个好的开始;更好的是,获得Eric van der Vlist的书并阅读开篇章节。
您提供给我们的片段格式不正确:它在第26行包含一个不匹配的</xs:attribute>
结束标记。如果我们添加了缺失的行:
<xs:attribute name='type' use='required'>
在第21行,然后架构定义了具有两个属性且没有内容的address
元素的规则:强制type
属性,其唯一允许值为bcc
,以及可选的uri
属性,其值为任何字符串。定义一个没有内容的元素是一种相当奇怪的方式:它实际上将它定义为具有内容的元素,其中内容必须是空字符串。也许架构设计师有理由这样做,但并不是很明显。