编译错误 "restriction date" XSD
Compile error with a "restriction date" XSD
我实际上被困在一个带有 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 上的语法。
我仍然看不出我的代码有什么问题,也许你们中的一个能找出来?
感谢您的帮助。
您的 xsd:attribute
元素同时具有 type
属性和 xsd:simpleType
子元素。你不能两者兼得。
不是很好的错误信息。当您收到糟糕的错误消息时,值得尝试使用不同的模式处理器。
Xerces 说:
Attribute 'date' has both a 'type' attribute and an anonymous
'simpleType' child. Only one of these is allowed for an attribute.
撒克逊人说:
Error at xsd:attribute
on line 14 column 56 of test.xsd: A
<simpleType>
element must not appear as a child of an <xsd:attribute>
with a @type
attribute
我认为无论是这些消息,你都不会在这里问这个问题。
我实际上被困在一个带有 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 上的语法。 我仍然看不出我的代码有什么问题,也许你们中的一个能找出来?
感谢您的帮助。
您的 xsd:attribute
元素同时具有 type
属性和 xsd:simpleType
子元素。你不能两者兼得。
不是很好的错误信息。当您收到糟糕的错误消息时,值得尝试使用不同的模式处理器。
Xerces 说:
Attribute 'date' has both a 'type' attribute and an anonymous 'simpleType' child. Only one of these is allowed for an attribute.
撒克逊人说:
Error at
xsd:attribute
on line 14 column 56 of test.xsd: A<simpleType>
element must not appear as a child of an<xsd:attribute>
with a@type
attribute
我认为无论是这些消息,你都不会在这里问这个问题。