[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] id function doesn't work in conjonction with a XML schema


Subject: Re: [xsl] id function doesn't work in conjonction with a XML schema
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 25 Jan 2002 12:55:03 +0000

Trevor Nash wrote:
> If you do not like replicating information in the schema in a
> hand-written xsl:key, then you could write a stylesheet which takes
> the schema as input and produces a stylesheet containing just some
> xsl:key definitions: import this into the main stylesheet. Maybe
> someone has already done this?

That's an interesting idea. The main difficulty, I think, is that
unlike keys in XSLT, keys in XML Schema are scoped within a particular
element. So to create the match attribute for the xsl:key in the
general case you would have to create a pattern that combines (a) the
xs:selector for the identity constraint (b) the name of the element in
which the identity constraint is defined and (c) the possible
ancestors for the element in which the identity constraint is defined.
Of course you might not have to worry about (b) and (c) for a
particular schema.

The other thing to take into account is that the xs:selector xpath
attribute holds a location path (admittedly using a fairly limited
syntax) whereas the xsl:key match attribute holds a pattern. You just
have to be a little careful about the '.' that you might find in the
xpath attribute.

I was kinda hoping that we'd get this kind of facility in XSLT 2.0 --
define the identity constraint in the schema and use it through the
key() function in XSLT. But that doesn't seem to be on the cards at
the moment; even the dereference operator (=>) only uses IDs, not
the more flexible identity constraints.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread