1

有谁知道 xml 模式中所谓的“唯一粒子属性”约束,以及为什么它可能会被违反:

  <xs:complexType name="SMIL.switch.content">
    <xs:sequence>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="smil:metadata"/>
        <xs:element ref="SMIL.switch-control"/>
      </xs:choice>
      <xs:choice>
        <xs:choice>
          <xs:sequence maxOccurs="unbounded">
            <xs:choice maxOccurs="unbounded">
              <xs:element ref="SMIL.timecontainer.class"/>
              <xs:element ref="SMIL.media-object"/>
            </xs:choice>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element ref="smil:metadata"/>
              <xs:element ref="SMIL.switch-control"/>
            </xs:choice>
          </xs:sequence>
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="smil:metadata"/>
            <xs:element ref="SMIL.switch-control"/>
          </xs:choice>
        </xs:choice>
        <xs:sequence minOccurs="0" maxOccurs="unbounded">
          <xs:element ref="smil:layout"/>
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="smil:metadata"/>
            <xs:element ref="SMIL.switch-control"/>
          </xs:choice>
        </xs:sequence>
      </xs:choice>
    </xs:sequence>
  </xs:complexType>

运行XJC报错如下:

[错误] cos-nonambig: " http://www.w3.org/ns/SMIL ":metadata 和 " http://www.w3.org/ns/SMIL ":metadata (或它们的替换组中的元素)违反“唯一粒子归属”。在针对此模式进行验证期间,将为这两个粒子创建歧义。

该模式是使用 trang 从 SMIL 3.0 DTD 生成的。

4

1 回答 1

4

如果验证会遇到 smil:metadata 元素,它无法知道它是否匹配外部序列的第一选择部分或第二选择部分。而 XML Schema 不允许这种歧义。

请参阅 XML Schema Recommendation 的附录 H,第 1 部分。

于 2010-11-23T15:10:26.570 回答