【发布时间】: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' 而不是
">。不知道为什么该行的最后两个字符使用 ASCII 文本 -
是的@tshimkus 我猜这只是一个复制过去的错误,因为它不像我的文件中的那样。
标签: xml date xsd attributes restriction