How to define a element involving regular expressions?

D. Alvarado

Usenet Archive
Joined
Apr 25, 2002
Messages
63
Reaction score
0
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?
 

Janwillem Borleffs

Usenet Archive
Joined
Oct 10, 2001
Messages
1,000
Reaction score
0
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
 

Henry S. Thompson

Usenet Archive
Joined
Jan 14, 2000
Messages
309
Reaction score
0
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
 

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

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,798
Members
249,594
Latest member
henrywalsh

Latest Threads

Top