根据空格的XML规范
对于所有的数据类型·派生·by·union·whiteSpace并不直接适用,但是,的规范化行为是由whiteSpace值控制的,而·union·types·对其进行了成功的验证。
和
用于字符串,whiteSpace的值是保存
基于该的,下面的示例不应该有效,因为应该保留字符串的空格,并且不应该满足模式。然而,它是有效的。所以,我的查询是,为什么这个XML对这个模式有效?
XML (请注意白色感受器):
<?xml version="1.0" encoding="UTF-8" ?>
<elem> Hello world</elem>XML (注意模式限制):
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="myUnion">
<xs:union memberTypes="xs:string">
</xs:union>
</xs:simpleType>
<xs:element name="elem">
<xs:simpleType>
<xs:restriction base="myUnion">
<xs:pattern value="Hello world" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>编辑: Xerces说它有效,Saxon说它无效。那似乎是Xerces的一个bug。
然而,如果我们这样定义工会:
<xs:simpleType name="myUnion">
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>再次,Xerces说它有效,Saxon说它无效。但这一次,它似乎是一个Saxon (因为空白应该被折叠,模式应该得到满足)。你觉得呢?
发布于 2014-12-05 10:59:08
谁说它是有效的?
撒克逊说:
Processing file:/Users/mike/Desktop/temp/test.xml
Validation error on line 2 of test.xml:
XSD: The content " Hello world" of element <elem> does not match the required
simple type. Value " Hello world" contravenes the pattern facet "Hello world"
of the type of element elem
Validating /elem[1]
See http://www.w3.org/TR/xmlschema11-2/#cvc-datatype-valid clause 1
Validation error on line 2 column 37 of test.xml:
XSD: One or more validation errors were reported
Validation unsuccessful而撒克逊人通常是对的-)
https://stackoverflow.com/questions/27307880
复制相似问题