This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: key with restricting the scope of use attribute



M>There's some basic misunderstanding here about what a key is.
M>Think of <xsl:key> as being like "create index" ...
M>it doesn't make sense to
M>change them depending on the contents of a variable.

I didn't know precisely when the key became "fixed" but
I am not trying to alter the key definition dynamically. 
I am trying to create a set of similar keys parameterized 
by the node I am visiting.

I need to traverse a set of nodes (//a/b) and at each node 
do some heavy processing involving repeated evaluation of 
a key to process other nodes (more or less underneath 
the node I am  visiting). At each node, lets say I need to
retrieve nodes associated with the combined value of @x and
@y. But I want to restrict the nodes returned by key() to those 
associated with the current node that I am visiting. So I
take the approach of building the use attribute from *three* pieces
of information @x, @y and something unique to the $CurrentNode
namely generate-id().

This is why I need to build the use key having part of it derived 
from the current node:

<xsl:key name="MyKey" match="a/b" 
   use="concat(generate-id(),':',@x,':',@y)"/>
               ^^^^^^^^^^^^^

<xsl:for-each select="key('MyKey',
   concat(generate-id(),':',$xyCombo))">
          ^^^^^^^^^^^^^                        

It appears to work, but I am a little uncertain if this is the
best appraoch to implement with. So I am asking for comments and
alternate suggestions.

Regards,

Dan

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]