【问题标题】:Element 'simpleType' is invalid, misplaced, or occurs too often元素“simpleType”无效、放错位置或出现太频繁
【发布时间】:2017-10-17 15:24:04
【问题描述】:

我不确定我做错了什么。但是错误如下:

s4s-elt-invalid-content.1:元素“simpleType”无效、放错位置或出现太频繁。

    <xsd:element name="amtNew" minOccurs="0">
        <xsd:complexType>
            <xsd:simpleType>
                <xsd:restriction base="xsd:decimal">
                    <xsd:totalDigits value="13" />
                    <xsd:fractionDigits value="3" />
                </xsd:restriction>
            </xsd:simpleType>
            <xsd:attribute name="code" use="required">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:token">
                        <xsd:length value="3" />
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:attribute>
            </xsd:complexType>
        </xsd:element>

【问题讨论】:

    标签: xslt xsd xml-parsing xsd-validation


    【解决方案1】:

    xsd:complexType 元素不能将 xsd:simpleType 作为子元素,因此您使用的文档对于架构文档的 XSD 架构无效。如果您的头脑中没有明确的架构文档架构(可能有些人这样做),如果您使用了解架构并可以检查架构文档的 XML 编辑器,您将省去很多麻烦至少对于模式有效性;如果您的编辑可以检查您的架构文档是否符合规范(这涉及一些超出单个架构文档有效性的约束),您将节省更多时间。

    在这种情况下,您似乎想要定义一个元素,其内容是最多 13 位的十进制数,并且需要携带名为 code 的属性。您想要的复杂类型具有“简单内容”,并且是简单类型内容的扩展;您应该查看架构(或教程)以获取有关 xsd:simpleContent 和 xsd:extension 元素的信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多