semi colon delimited xs:attribute xsd
I'm currently building an XSD to validate some XML I'm working on, I'm guessing this probably isn't possible but I'm wondering if there is some way to enforce an attribute that is a ";" delimited list for example
<nbsp style="cell-width:1.29;background-color:#99CC00;"/>
s开发者_如何学Goimilar to the way the style attribute works in html.
Thanks in advance
You can specify a type which must match a specific pattern.
Example:
<simpleType name='better-us-zipcode'>
<restriction base='string'>
<pattern value='[0-9]{5}(-[0-9]{4})?'/>
</restriction>
</simpleType>
Use a regular expression to validate the content.
<xs:attribute name="code">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z][A-Z]"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
see also
http://www.w3schools.com/Schema/el_attribute.asp and http://www.w3schools.com/schema/schema_simple_attributes.asp and http://www.w3schools.com/schema/schema_facets.asp
test your regexp here: http://regexlib.com/RETester.aspx
精彩评论