【发布时间】:2017-02-02 15:55:00
【问题描述】:
我的XSD如下
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="AttNode">
<xs:complexType>
<xs:sequence>
<xs:element ref="AttNodeChild"/>
</xs:sequence>
<xs:attributeGroup ref="AttNodeGroup"/>
</xs:complexType>
</xs:element>
<xs:attributeGroup name="AttNodeGroup">
<xs:attribute ref="att" use="required"/>
</xs:attributeGroup>
<xs:attribute name="att" type="patternAtt" />
<xs:simpleType name="patternAtt">
<xs:restriction base="xs:normalizedString">
<xs:pattern value="(|[TT]|YY|UU)(,(|[TT]|YY|UU))"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
XSD 验证在属性值低于模式时工作正常,但我不会将属性值设为 null
<AttNode>
<AttNodeChild att="YY,UU"/>
</AttNode>
我尝试在 Pattern 中使用特殊字符提供 Null 检查和 String 值但失败了,请发表您的建议
验证失败
案例 01:
<AttNode>
<AttNodeChild att="[TT],UU"/>
</AttNode>
案例 02:
<AttNode>
<AttNodeChild att=""/>
</AttNode>
【问题讨论】: