[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: Linking acronym to a glossary entry
At 99/08/31 15:07 +0100, DPawson@xxxxxxxxxxx wrote:
given
<p>blah <acronym>RNIB</acronym> blah </p>
....
<glossary>
<term>RNIB</term><defn> Royal </defn>
....
</glossary>
I suggest you add a container element to easily associate the definition
with the term, though I ended up not needing the container as I thought I
would.
is it possible to create a link between
the use of the acronym in the p element
and the term element in the glossary?
I think it would be fast and easy with key(), but that isn't implemented
yet in XT so my suggestion below is a "slow" way.
I'm OK using generate-id() on the glossary term,
but I'm stuck on generating the <a href contents ....
I (think I) need to
1. find the matching term (with what construct?)
Content comparison.
2. then use generate-id(.)
An example is below ... I hope this helps.
........ Ken
T:\dave>type test.xml
<?xml version="1.0"?>
<test>
<body>
<p>blah <acronym>RNIB</acronym> blah </p>
</body>
<glossary>
<def><term>RNIB</term><defn> Royal </defn></def>
<def><term>XSLT</term>
<defn> <acronym>XSL</acronym> Transformations</defn></def>
<def><term>XSL</term><defn>Extensible Stylesheet Language</defn></def>
</glossary>
</test>
T:\dave>type test.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
<xsl:output method="xml"/>
<xsl:template match="p|def">
<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="acronym"> <!--find term with same content as acro-->
<a href="#{generate-id(//def/term[.=current()])}">
<xsl:value-of select="."/>
</a>
</xsl:template>
<xsl:template match="term">
<a name="{generate-id(.)}"><b><xsl:value-of select="."/></b>: </a>
</xsl:template>
</xsl:stylesheet>
T:\dave>call xsl test.xml test.xsl test.htm
T:\dave>type test.htm
<p>blah <a href="#N15">RNIB</a> blah </p>
<p><a name="N15"><b>RNIB</b>: </a> Royal </p>
<p><a name="N21"><b>XSLT</b>: </a>
<a href="#N31">XSL</a> Transformations</p>
<p><a name="N31"><b>XSL</b>: </a>Extensible Stylesheet Language</p>
T:\dave>
--
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
Website: XSL/XML/DSSSL/SGML services, training, libraries, products.
Practical Transformation Using XSLT and XPath ISBN 1-894049-01-2
Next instructor-led training: MT'99 1999-12-05/06
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|