You shouldn't have the filename or the hash (#) symbol in the anchor
name. In the href they tell the browser to go to the specified file,
then find the anchor with the name after the hash, so the value of your
name attribute should just be:
seriesX
I'm also doubtful that position will work as you expect outside of a
for-each loop. As others have suggested, generate-id should be the
solution. Unfortunately with your current setup, this will generate an
id for the unittitle node, and the ToC generating code is operating on
c01 nodes. Also you'd need the anchor creating code in the templates for
subseries, subgrp and subcollection.
Id be tempted to do something like the following then (untested so
apologies if it's not perfect):
<xsl:template match="c01">
<a>
<xsl:attribute name="name">
<xsl:value-of select="generate-id()"/>
</xsl:attribute>
</a>
<xsl:choose>
<xsl:when test="@level='series'">
<h4>
<xsl:apply-templates select="did/unittitle"/>
</h4>
</xsl:when>
<xsl:when test="@level='subseries'">
...
</xsl:when>
...
<!-- all other c01s that need to be dealt with in a particular way -->
<xsl:otherwise>
<!-- default case -->
</xsl:otherwise>
</xsl:choose>
...
<!-- whatever else needs to be done for c01s -->
</xsl:template>
You'd then need to modify the code that generates the ToC links to
something like:
<xsl:for-each select="archdesc/dsc/c01[@level='series' or @level='subseries' or @level='subgrp' or @level='subcollection']">
<p style="margin-left:10pt; font-size:10pt">
<b>
<a>
<xsl:attribute name="href">
<xsl:value-of select="$file"/>
<xsl:text>b.html#</xsl:text>
<xsl:value-of select="generate-id()"/>
</xsl:attribute>
</a>
</b>
</p>
</xsl:for-each>
One important point to make about generate-id is that it will generate
the same id for a given node, every time it is called within a single
transformation. However, it may not return the same id for that given
node within subsequent transformations. The upshot being that you need
to generate the ToC during the same transformation as the rest of the
document.
HTH
John
On Tue, 2008-05-20 at 17:27 -0400, Lynn Lobash wrote:
> Does anyone know how to write this anchor tag?
>
>
> <!--This template formats various head (here, series unittitles)
> elements and makes them targets for links from the Table of
> Contents.-->
>
> <xsl:template match="c01[@level='series']/did/unittitle">
> <h4>
> <a name="?">
>
> <!--The path needs to read ($file)b.html#series + position(), for
> example:filenameb.html#series2, see href established in TOC pasted
> below. -->
>
> <xsl:apply-templates/>
> </a>
> </h4>
> </xsl:template>
>
> <!-- Displays the unittitle and unitdates for a c01 if it is a series
> (as
> evidenced by the level attribute series)and numbers them
> to form a hyperlink to each. -->
>
>
> <xsl:for-each select="archdesc/dsc/c01[@level='series' or
> @level='subseries'
> or @level='subgrp' or @level='subcollection']">
> <p style="margin-left:10pt; font-size:10pt">
> <b>
> <a>
> <xsl:attribute name="href">
> <xsl:value-of
> select="$file"/>b.html#series<xsl:number value="position()"
> format="1"/>
> </xsl:attribute>
> </a>
> </b>
> </p>
> </xsl:for-each>
>
> Thanks you,
> Lynn
--
John Harrison <[log in to unmask]>
University of Liverpool Library
|