Re: A XPath expresion

Joan Pujol <joan.pujol@ima.udg.es> writes:

> This break my rules, because Group don't provide a namespace and
> there are two elements with the same name:

> <Struct name='Film'>
> 	<Scalar name='Title'>
> 	<Group name='Group1'>
> 		<Scalar name='Title'>
> 	</Group>
> </Struct>
> 	
> but this don't:
> Because the struct provides another 'namespace' for his children elements.
> <Struct name='Film'>
> 	<Scalar name='Title'>
> 	<Struct name='Struct1'>
> 		<Scalar name='Title'>
> 	</Struct>
> </Struct>
> 
> Can I expresse it with Schema Identity Constraints?

So we have three facts:
1) Struct is the scoping element, so the key constraint must be
declared there;
2) Struct's nest and are opaque for key uniqueness, so the selector
pattern can't be './/Scalar';
3) The XPath expression language, much less the subset used in XML
Schema, doesn't allow you to rule out a particular tag at any point in 
a path.

So the best you can do is to explicitly specify the necessary disjunction, e.g.

  <selector xpath='Scalar|Group/Scalar'/>

If Group can nest arbitrarily, you can't cover that.  If in practice
the depth will be limited to, say, depth 3, then

  <selector
   xpath='Scalar|Group/Scalar|Group/Group/Scalar|Group/Group/Group/Scalar'/>

would do.

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/

Received on Wednesday, 7 November 2001 05:24:08 UTC