xsl-list
[Top] [All Lists]

Re: Severe limitation of the xsl:key element with multiple source doc uments

2002-12-10 18:01:11
Jerome Louvel wrote:
But now we need to define XSLT keys in our source documents so we tried to
use the following declaration:
<xsl:key name="key_1" match="document('id:042C5210')/codesTable/entry/value"
use="../code" />

And we discovered that Xalan rejects this because of the presence of the
document() function call.
After checking the spec we discovered that the "match" attribute of the
xsl:key element must be a pattern (http://www.w3.org/TR/xslt#NT-Pattern) and
not an expression (http://www.w3.org/TR/xpath#NT-Expr).

This prevents us from declaring any keys in our case which we find to be a
severe limitation in XSLT 1.0.
So we checked latest XSLT 2.0 working draft and found that the same
constraint.

Are we missing something? 

Yes, you apparently didn't see XSLT 1.0 section 12.2, at the very end. It
tells you how to do exactly what you're asking for.

A key applies to nodes that match a pattern, no matter what document they
occur in. The key *function*, however, only checks the keys of nodes in the
document containing the context node. So just change the temporarily context
node with xsl:for-each before you call key().

Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

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



<Prev in Thread] Current Thread [Next in Thread>