How to define a element involving regular expressions?

D

D. Alvarado

Hello,
I have an element that I would like to validate against an XML
schema in which the element can be either one of 50 values or an
arbitrary number of white space characters. The values would be
things like "AC", "AD", abd "AF" and you could see the XML element
represented like:

<myElt>AC</myElt>

or

<myElt>AF</myElt>

or

<myElt> </myElt>

How would I define such an element in an XML schema?
 
J

Janwillem Borleffs

D. Alvarado said:
Hello,
I have an element that I would like to validate against an XML
schema in which the element can be either one of 50 values or an
arbitrary number of white space characters. The values would be
things like "AC", "AD", abd "AF" and you could see the XML element
represented like:
[...]
How would I define such an element in an XML schema?

The boundaries are not too clear, but the following simple type might get
you on your way:

<xs:simpleType name="patternType">
<xs:restriction base="xs:string">
<xs:pattern value="[ ]{11}|A[C-F]" />
</xs:restriction>
</xs:simpleType>


JW
 
H

Henry S. Thompson

I have an element that I would like to validate against an XML
schema in which the element can be either one of 50 values or an
arbitrary number of white space characters. The values would be
things like "AC", "AD", abd "AF" and you could see the XML element
represented like:

<myElt>AC</myElt>
or
<myElt>AF</myElt>
or
<myElt> </myElt>

How would I define such an element in an XML schema?

Define a restriction of xs:token with either
* an enumeration of all your two-letter codes plus the empty string
or
* a pattern which allows the empty string plus your two letter codes

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top