有人知道为什么以下不起作用? xsd通过Xerces验证
<xs:element name="myElement">
<xs:complexType>
<xs:complexContent>
<xs:extension base="myElementType">
<xs:assert test="firstname = 'George' and lastName = 'Mc'Falrland'" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
当我使用单引号'
实体...
由于
答案 0 :(得分:2)
你的问题与XPath字符串文字有关,因为XSD 1.1使用XPath 2.0你可以通过写分隔符两次来转义字符串文字中的撇号或引号,这样你就可以使用:
<xs:assert test="firstname = 'George' and lastName = 'Mc''Falrland'" />
有关详情,请使用XPath 2.0 specs, section Literals:
如果文字由撇号分隔,则为两个相邻的撇号 在文字内被解释为单个撇号。同样的, 如果文字用引号分隔,则两个相邻的引号 文字中的标记被解释为一个引号。