Re: [xsl] Keying over added attributes in temporary tree

Subject: Re: [xsl] Keying over added attributes in temporary tree
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 27 Jan 2006 15:38:15 GMT
  I would assume that the keys are created before starting the "/" template.
  The xsl:key element is not allowed in a template, so that can't force
  the re-indexing for the key.

The specification doesn't say when they are created, but in practice for
performance reasons most systems only create them when (if) they are
referenced by key(). keys (separately) index all trees, there is no way
to specify an key only applies to one tree. So if you use xsl:key when
the current node is in a temporary tree (or if you supply a node in a
temporary tree as third argument) then that tree will be indexed using
the specified key.

  1) Is the xsl:variable "objects-with-new" considered a "temporary
     tree"?
The value of that variable is a (document node of a) temorary tree, yes.

2) Is it possible to access the "object" elements in $objects-with-new
via a key, where the @use is an attribute that was added after parsing
the input document?

Yes

key('objects-by-new','a') if the current node is a descendant of
$objects-with-new or
key('objects-by-new','a',$objects-with-new) otherwise.

so for example

     20   <xsl:copy-of select="$objects-with-new//object[@new=2]"/>


could be

     20   <xsl:copy-of select="$objects-with-new/key('objects-by-new','2') "/>

or

     20   <xsl:copy-of select="key('objects-by-new','2',$objects-with-new) "/>

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread