views:

22

answers:

2

Hey,

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;"/>

similar to the way the style attribute works in html.

Thanks in advance

+1  A: 

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>
Sjoerd
Thanks, I'm aware of this but this intention is to get some context help if possible
mjmcloug
+1  A: 

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

Marc van Kempen