Keys in XSL
My search for a utility that will allow me to reference one part of a document in another has zeroed in on the <xsl:key> command. Essentially, if for example I have a bibliography entry in one part of a document, and I need to reference that entry in another part, I need a utility that will permit it.
The easiest implemention I have found so far is a simplified version of the example found at http://nwalsh.com/docs/tutorials/xsl/xsl/foil68.html. It uses the following xml and xsl examples:
<?xml version=”1.0″ encoding=”UTF-8″?>
<doc>
<para>See <bibref>xyzzy</bibref>.
</para>
<biblio>
<bib abbrev=”xyzzy”>The Great Grue</bib>
<bib abbrev=”abcde”>That Alphabet Song</bib>
</biblio>
</doc>
<?xml version=”1.0″?>
<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” xmlns:fo=”http://www.w3.org/1999/XSL/Format”><xsl:key name=”bibkey” match=”//biblio/bib” use=”@abbrev”/>
<xsl:template match=”doc”>
<xsl:apply-templates/>
</xsl:template><xsl:template match=”biblio”>
<!– suppressed –>
</xsl:template><xsl:template match=”para”>
<xsl:apply-templates/>
</xsl:template><xsl:template match=”bibref”>
<xsl:apply-templates select=”key(’bibkey’,string(.))”/>
</xsl:template></xsl:stylesheet>