派生类型的XML架构验证失败

时间:2013-08-08 01:49:28

标签: xml validation schema

我想知道什么是定义为XSD simpleType的XSD属性的类型,因此下面的模式失败验证。请在此处获取一个战利品,架构验证工具在“*”划分区域抛出错误,说基本属性类型未正确导出。不确定这是否是正确的结构来定义...我没有业务模型aroud这个,我只想尝试在这里使用不同的限制和扩展选项..

    <xsd:complexType name="comptype_simplecontent">
      <xsd:simpleContent>
        <xsd:restriction base="AAA">
            <xsd:attribute name="aaa_attr" *type="xsd:anySimpleType"*></xsd:attribute>
        </xsd:restriction>
      </xsd:simpleContent>
   </xsd:complexType>

   <xsd:complexType name="AAA" block="extension"> 
    <xsd:simpleContent> 
        <xsd:extension base="xsd:integer">
            <xsd:attribute name="aaa_attr">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:decimal">
                        <xsd:minExclusive value="90"></xsd:minExclusive>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:attribute>
        </xsd:extension>
    </xsd:simpleContent> 
</xsd:complexType> 

1 个答案:

答案 0 :(得分:1)

AAA定义具有整数内容和十进制属性的复杂类型;一个例子可能是

<X aaa_attr="93.7">5</X>

您将comptype_simplecontent定义为对此的限制,这意味着它允许的元素必须是AAA允许的元素的子集。但是在您的限制中,您可以说它可以取任何值(anySimpleType),而不是缩小属性中允许的值范围。这是不允许的;受限制的类型不允许其基本类型不允许的内容。

相关问题