半冒号分隔的xs:属性xsd

时间:2010-07-05 13:43:42

标签: attributes xsd

我正在构建一个XSD来验证我正在处理的一些XML,我猜这可能是不可能的,但我想知道是否有某种方法来强制执行一个属性“;”例如分隔列表

<nbsp style="cell-width:1.29;background-color:#99CC00;"/>

类似于样式属性在html中的工作方式。

提前致谢

2 个答案:

答案 0 :(得分:1)

您可以指定必须与特定pattern匹配的类型。

示例:

<simpleType name='better-us-zipcode'>
  <restriction base='string'>
    <pattern value='[0-9]{5}(-[0-9]{4})?'/>
  </restriction>
</simpleType>

答案 1 :(得分:1)

使用正则表达式验证内容。

<xs:attribute name="code">

<xs:simpleType>
  <xs:restriction base="xs:string">
    <xs:pattern value="[A-Z][A-Z]"/>
  </xs:restriction>
</xs:simpleType>

</xs:attribute> 

另见

http://www.w3schools.com/Schema/el_attribute.asp 和   http://www.w3schools.com/schema/schema_simple_attributes.asp 和   http://www.w3schools.com/schema/schema_facets.asp

在此处测试您的正则表达式:http://regexlib.com/RETester.aspx