XML schema syntax for comma-delimited integer element

S

scott.ballard

Greetings,

I would like to know if it is possible in an XML Schema to specify an
element that contains comma-delimted integers? For example,

<element>1,2,3,4,5,6,7,8,9</element>

Now I know you might say it's better to split the array into distinct
elements. However, some of the elements will have so many integers
that the overhead of the extra XML tags will bloat the file. So back
to my original question, is it possible to specify this element format
in XML Schema? If so, what would it look like? Thank you.

Regards,

Scott Ballard
 
S

Stan Kitsis [MSFT]

Hi Scott,

The following should do it:

<xs:simpleType name="listofIntsType">

<xs:restriction base="xs:string">

<xs:pattern value="(\d,)*\d"/>

</xs:restriction>

</xs:simpleType>



<xs:element name="myDigits" type="listofIntsType"/>


--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
D

David Carlisle

is it possible to specify this element format
in XML Schema?

no but you can specify space separated integers.
or you can specify a string with a regexp facet that only matches a
comma separated list of digits.

David
 

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
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top