NEWBIE: XML restriction query

V

Victor

Hi, I have defined the following that limits values for <COUNTING> to
be ONE, TWO or THREE. I want to modify it so the base isn't a string
anymore but a long, and accept ANY long as valid, but I still want to
accept the values ONE, TWO, or THREE. Can this be done?

Thank you
Victor


<xs:simpleType name="COUNTING">
<xs:restriction base="xs:string">
<xs:enumeration value="ONE"/>
<xs:enumeration value="TWO"/>
<xs:enumeration value="THREE"/>
</xs:restriction>
</xs:simpleType>



The following would be valid against a new restriction

ONE
TWO
17
65
THREE
ONE
765
861
12
67



The following would be invalid
ONE
TWO
FOUR
17
65
THREE
ONE
765
 
B

BarryNL

Victor said:
Hi, I have defined the following that limits values for <COUNTING> to
be ONE, TWO or THREE. I want to modify it so the base isn't a string
anymore but a long, and accept ANY long as valid, but I still want to
accept the values ONE, TWO, or THREE. Can this be done?

You could use a regular expression as the restriction, eg:
"ONE|TWO|THREE|[1-9][0-9]+"
 
V

Victor

Thanks - so simple.
Victor.

BarryNL said:
Victor said:
Hi, I have defined the following that limits values for <COUNTING> to
be ONE, TWO or THREE. I want to modify it so the base isn't a string
anymore but a long, and accept ANY long as valid, but I still want to
accept the values ONE, TWO, or THREE. Can this be done?

You could use a regular expression as the restriction, eg:
"ONE|TWO|THREE|[1-9][0-9]+"
Thank you
Victor


<xs:simpleType name="COUNTING">
<xs:restriction base="xs:string">
<xs:enumeration value="ONE"/>
<xs:enumeration value="TWO"/>
<xs:enumeration value="THREE"/>
</xs:restriction>
</xs:simpleType>



The following would be valid against a new restriction

ONE
TWO
17
65
THREE
ONE
765
861
12
67



The following would be invalid
ONE
TWO
FOUR
17
65
THREE
ONE
765
 

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,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top