|
[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








