OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [xml-dev] Unique values in XML documents



Matt, 

Neither DTD nor XML Schema let you check or enforce that all
character data  of a certain element type is unique across
multiple documents.  It must be done by an application.

To ensure that the values are unique when they are created you
can follow some convention, such as concatenating the name of
the file and a sequential counter into the unique values.
Depending on the nature of the application, time stamps might be
useful.  Fancier applications might use a "ticket server" that
issues sequential (or otherwise unique) strings or numbers.

To check the uniquness of the values of attributes of type ID
across multiple documents I've often created a new DTD which
includes all of the old DTD plus a new root element, say
big_collection, which has as its content model (old_root+).
Concatenate all of the existing documents into one big document,
with the new <big_collection>...</big_collection> "wrapper" and
validate.

If the values to be checked are character data you can copy them
into a new ID-type attribute as you concatenate them into the
single big file and then use a validating parser.  Another easy
approach to check the character content of all of your "id"
elements would be to create ESIS or PYX output for each XML file
and then write a short program to process the ESIS (or PYX),
looking for duplicates.


/s/ Ernest G. Allen
    Sunnyvale, CA



At 3:12 PM -0700 2001-09-24, Christian Nentwich wrote:
>> At 9:04 AM -0700 2001-09-24, Matt Loryman wrote:
>> I have a series of XML documents. I want to ensure that when any of these
>> documents
>> contains the following element:
>> <id></id>
>> That the value supplied is unique across all <id> elements contained in all
>> the documents.
>
>You can do this quite easily in xlinkit (see http://www.xlinkit.com) as
>follows:
>
><forall var="x" in="//id">
>  <forall var="y" in="//id">
>    <implies>
>      <equals op1="$x/text()" op2="$y/text()"/>
>      <same op1="$x" op2="$y"/>
>    </implies>
>  </forall>
></forall>
>
>Depending on how complex your constraints get, this may/may not be
>inconvenient for you.
>
>Christian
>
>
>