【发布时间】:2022-01-05 20:15:46
【问题描述】:
我有一个关于 xml 架构的问题。我真的不知道如何正确使用选择。 这是我的 xml 文本。
<serials>
<serial>
<title></title>
<country></country>
<director></director>
<release date></release date>
</serial>
.
.some of the same as the one above
.
<serial>
<title></title>
<country></country>
<director></director>
<uncertaine></uncertainee>
</serial>
<serial>
<title></title>
<country></country>
<director></director>
<scheduled time></scheduled time>
</serial>
</serials>
这是 xml 架构的问题部分
<xsd:group name="serialData">
<xsd:choice>
<xsd:sequence>
<xsd:element name="title" type="xsd"string"/>
<xsd:element name="country" type="xsd"string"/>
<xsd:element name="director" type="xsd"string"/>
<xsd:element name="release date" type="xsd"string"/>
</xsd:sequence>
<xsd:sequence>
<xsd:element name="title" type="xsd"string"/>
<xsd:element name="country" type="xsd"string"/>
<xsd:element name="director" type="xsd"string"/>
<xsd:element name="scheduled time" type="xsd"string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="uncertaineetime" type="xsd"string" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:choice>
</xsd:group>
问题是后者非典型系列想要与前者相同的属性,但不能拥有它们。
【问题讨论】:
-
您的 XML 格式不正确。标签名称中不允许有空格。在修复 XML 之前,您无法解决 XML 架构问题。
-
这里的起始节点也不匹配结束
并且不匹配您架构中的名称。 -
另外,您的示例与 XSD 中的结构不匹配,因为您在同一个示例中没有预定时间和不确定时间
标签: xml xsd xsd-validation