make a unbroken sequence of id attribute with XSD

E

eephyne

hello

i would like to know if its possible to make a unbroken sequence of id attribute in XSD, meaning

<object id="0" />
<object id="2" />
<object id="1" />

would be correct but

<object id="0" />
<object id="2" />
<object id="3" />

would be not

id must start from 0 and all numbers must be present (order/sort doesn't matter) , this is of course for an undefined quantity of object.

thanks
 
M

Martin Honnen

eephyne said:
i would like to know if its possible to make a unbroken sequence of id attribute in XSD, meaning

<object id="0" />
<object id="2" />
<object id="1" />

would be correct but

<object id="0" />
<object id="2" />
<object id="3" />

would be not

id must start from 0 and all numbers must be present (order/sort doesn't matter) , this is of course for an undefined quantity of object.

Well XML IDs are not allowed to start with a digit at all.
Of course you could define your "id" attribute as an integer (instead of
as an ID) and define a uniqueness constraint but I don't know of a way
with the version 1 of the W3C schema language to ensure the "unbroken"
sequence of values.
The version 2 of the schema language is under development, it allows to
define assertions with XPath 2.0 expressions, it might be possible that
way, I will look into that later. There are early implementations with
Saxon 9.3 (only the commercial version) and with Java Xerces so you
could consider that.
 
A

Alain Ketterlin

eephyne said:
i would like to know if its possible to make a unbroken sequence of id attribute in XSD, meaning

<object id="0" />
<object id="2" />
<object id="1" />

would be correct but

<object id="0" />
<object id="2" />
<object id="3" />

would be not

id must start from 0 and all numbers must be present (order/sort
doesn't matter) , this is of course for an undefined quantity of
object.

I don't know what meaning your "id" attribute carries, but do you need
it at all? Why not simply use node position?

-- Alain.
 

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,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top