You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Andy Clark <an...@apache.org> on 2001/01/25 09:37:14 UTC

[Schema] Identity Constraint Support!

I just checked in support for XML Schema identity constraints.
At the moment, it's just very basic support for unique, key,
and keyref on element declarations. If you checkout the code
from CVS (make sure to use "update -d") you can start playing
with it.

The following are some of the limitations of the new code:

1) There is not enough error checking performed. Therefore,
   if you don't use the correct identity constraint syntax
   or don't pay heed to the limitations listed here, don't
   be surprised if the parser barfs on your shoes. Just
   giving you fair warning here, folks.

2) The XPaths used for specifying selectors and fields is
   a subset of XPath. Currently, only the self, child, and
   attribute axes are supported -- nothing more! In the
   future, simple predicate support and the ability to 
   specify unions can be added.

   A subset of XPath was chosen to make the code easy to
   implement and understand, as well as being efficient. The
   subset allows the XPaths to be matched in a serial manner
   and doesn't require any part of the document to be
   buffered. This allows identity constraints support to be
   implemented in DOM *and* SAX. Neat!

   Here are some examples of selector and field XPaths that
   can be used:

     .
     foo
     foo/bar
     foo/@baz   // only for fields
     @baz       // only for fields

   Short of having basic predicates and unions, you should
   be able to define a lot of useful identity constraints
   with the subset.

3) Field values are currently compared in the lexical space. 
   Therefore, the values "1" and "1.0" are NOT equal for a 
   field of type "decimal" (even though they should be).

   The XML Schema spec requires that field values be compared 
   in the value space for those fields. However, this requires
   me to "discover" what elements and attributes are pointed
   to by the selector/field(s). And since I had just written
   one XPath matching algorithm (the serial match in the
   instance document), I didn't feel like writing another
   one (to match in the grammar description) before I checked
   in my code.

   However, fixing this isn't too difficult. In fact it's
   easier than matching serially in the document instance
   because you don't have to keep track of what step you're
   on as you go in and out of elements within the scope. If
   anyone wants to go ahead and implement this, let me know
   so that we don't duplicate effort.

There are probably more limitations but these are the
important ones.

-- 
Andy Clark * IBM, TRL - Japan * andyc@apache.org

Re: [Schema] Identity Constraint Support!

Posted by Grégoire Pau <gp...@acland.fr>.
From: "Andy Clark" <an...@apache.org>

> I just checked in support for XML Schema identity constraints.
> At the moment, it's just very basic support for unique, key,
> and keyref on element declarations. If you checkout the code
> from CVS (make sure to use "update -d") you can start playing
> with it.

I just checked out the last CVS version of xerces-J and I can't
parse with validation neither the XML Primer Purchase order
example (CR Oct, 24) nor the examples bundled in the xerces-J package
in the data directory (personal-order.xml personal.xsd). I've got a
null pointer exception and it seems that the parser can't
find the schema associated with the document file (although it was
specified with xsi:schemaLocation).

Maybe I have missed something ?

Regards

Grégoire Pau