【问题标题】:Compile error with a "restriction date" XSD使用“限制日期”XSD 编译错误
【发布时间】:2019-07-06 00:19:25
【问题描述】:

我实际上被困在 xsd 属性日期的作业中,我想在其中设置 minInclusive 和 maxInclusive 限制。这是我的代码(我的问题在前面:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema%22%3E
   <xsd:element name="cdtheque">
     <xsd:complexType> <xsd:sequence minOccurs="0">
        <xsd:element name="cd">
          <xsd:complexType>
            <xsd:all>
               <xsd:element name="titre" type="xsd:string"/>
               <xsd:element name="style" type="xsd:string"/>
               <xsd:element name="artiste" type="xsd:string"/>
             </xsd:all>
           </xsd:complexType>
         </xsd:element>
       </xsd:sequence>
        <xsd:attribute type="xsd:date" name="date">   <--------
          <xsd:simpleType>
          <xsd:restriction base="xsd:date">  
            <xsd:minInclusive value="1990-01-01"/>
            <xsd:maxInclusive value="2030-01-01"/>
          </xsd:restriction>
        </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute type="xsd:string" name="proprietaire"/>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>

我失败了:

xmllint --noout --schema ex3schema.xsd ex3.xml
ex3schema.xsd:15: element restriction: Schemas parser error : 
Element '{http://www.w3.org/2001/XMLSchema%7Dattribute': 
The content is not valid. Expected is (annotation?, simpleType?).
WXS schema ex3schema.xsd failed to compile

我是初学者,但是这几天我浏览了很多互联网网站,我一次又一次地检查了 W3S 上的语法。 我仍然看不出我的代码有什么问题,也许你们中的一个人能找到这个?

感谢您的帮助。

【问题讨论】:

  • 让我大吃一惊的是第一行,你有 '%22%3E' 而不是 "&gt;。不知道为什么该行的最后两个字符使用 ASCII 文本
  • 是的@tshimkus 我猜这只是一个复制过去的错误,因为它不像我的文件中的那样。

标签: xml date xsd attributes restriction


【解决方案1】:

您的xsd:attribute 元素同时具有type 属性和xsd:simpleType 子元素。你不能两者兼得。

不是一个很好的错误消息。当您收到一条糟糕的错误消息时,值得尝试使用不同的架构处理器。

Xerces 说:

属性“日期”同时具有“类型”属性和匿名属性 'simpleType' 孩子。一个属性只能使用其中之一。

撒克逊人说:

test.xsd 的第 14 行第 56 列 xsd:attribute 处出错:A &lt;simpleType&gt; 元素不能作为 &lt;xsd:attribute&gt; 的子元素出现 带有@type 属性

我认为,对于这些消息中的任何一个,您都不会在这里提出问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-29
    • 2014-06-09
    相关资源
    最近更新 更多