[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

using xsl:key to generate list of back references

Subject: using xsl:key to generate list of back references
From: "Sebastian Rahtz" <sebastian.rahtz@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 May 2000 00:14:38 +0100
using xsl key
The Muench insight rules.

Using TEI markup, where we see things like <ptr target="foo"/> to make 
links, I realized it was easy to get a cross-referenced list of links:

<xsl:key name="targets" match="ptr" use="@target"/>

......
 <xsl:for-each 
     select="//ptr[generate-id(.)=generate-id(key('targets',@target)[1])]">
   <xsl:sort select="@target"/>
   Key <xsl:value-of select="@target"/>
   <xsl:for-each select="key('targets',@target)">
     <xsl:sort select="name(.)"/>
     Referred to in  section  
      <xsl:apply-templates mode="header" select="ancestor::div[last()]"/>
   </xsl:for-each>
 </xsl:for-each>

which generates, eg,

Key history.def
     Referred to in  section  3.2
Key ignores.def
     Referred to in  section  3.1
Key msad
     Referred to in  section  2.1
     Referred to in  section  Appendix A.ii
Key msadac
     Referred to in  section  Appendix A.ii
Key msadad
     Referred to in  section  2.3
     Referred to in  section  2.8
     Referred to in  section  Appendix A.ii

which makes me pretty happy. 

What bothers me is the (relative) inelegance of

 <xsl:for-each 
     select="//ptr[generate-id(.)=generate-id(key('targets',@target)[1])]">

when what I really want to say is something like

 <xsl:for-each select="key('targets','')">

and somehow access the indices of the key structure. Is this
unreasonable of me? The processor has all the information I want,
right to hand, but it forces me to send it off on a wild goose chase
of 
  //ptr[generate-id(.)=generate-id(key('targets',@target)[1])]

which is boring.

Anyone up for Yet Another Extension?

Sebastian Rahtz


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.