属性和子项之间的选择无法表示。逼近

时间:2014-05-27 07:13:35

标签: xml relaxng

在我必须处理一些.rng文件的项目中,我收到一个错误“属性和子项之间的选择无法表示。近似”,这是我无法解决的。问题出现在这段代码中:

       <element name="maintenance-mode">
          <choice>
             <group>
              <attribute name="on-install">
                <data type="boolean"/>
              </attribute>
              <attribute name="on-remove">
                <data type="boolean"/>
              </attribute>
            </group>
            <group>
              <optional>
                <attribute name="on-install">
                  <data type="boolean"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="on-remove">
                  <data type="boolean"/>
                </attribute>
              </optional>
              <data type="boolean"/>
            </group>
          </choice>
        </element>

我无法找到问题的根本原因。

1 个答案:

答案 0 :(得分:0)

我收到您报告的消息的唯一方法是,我尝试将您的Relax NG架构(rng)转换为带有trang的XML架构(xsd)。因此,建议您使用trang(但不在问题中说明这一点),或者您正在使用在幕后使用trang的内容,或者您​​使用的软件基于trang

你得到的警告是因为Relax NG能够代表元素和属性之间的选择。您对maintenance-mode的声明允许它具有属性on-installon-remove或具有相同名称的子元素,但不包含属性和元素。 XML Schema无法对此约束进行建模,因此trang必须输出比其获得的Relax NG模式更通用(允许更多)的XML模式。生成的模式允许元素具有属性。