|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Automatically Generating Indexes
All,
I've been working on some stylesheets for a local version of TEI lite and have hit a wall with the "index" element, which is used to associate index terms with a specific point in the text: <p><index level1="Africa" level2="colonial"/>Settler colonies differed from colonies of exploitation by attracting a much larger population of European men and women for permanent settlement....</p> It was fairly easy to write a module (see below) to generate an index as a unordered list with links to the points in the text using "generate-id". But I'd like to try for something even closer to the print version, with different links to identical terms sequentially listed after that term and level2 terms collected under the correct level1 terms, etc. Has anyone had any luck with manipulations of this sort? This: Abandonment, international policy of: Link1, Link2 Abortion: Link1 Accommodation: Link1, Link2, Link3 Accommodation, foreign funding and: Link1 Accommodation, right wing and: Link1, Link2 Accommodation, violence and: Link1, Link2 Accommodation, Yugoslavian situation compared: Link1 Rather than this: Abandonment, international policy of: Link Abandonment, international policy of: Link Abortion: Link Accommodation: Link Accommodation: Link Accommodation: Link Accommodation, foreign funding and: Link Accommodation, right wing and: Link Accommodation, right wing and: Link Accommodation, violence and: Link Accommodation, violence and: Link Accommodation, Yugoslavian situation compared: Link <!-- index.xsl Index Generation Module--> <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"> <xsl:template match="index">
<a name="{generate-id(.)}"></a>
</xsl:template><xsl:template name="book.index">
<div class="index">
<h2>Index</h2>
<a name="index"></a>
<ul class="nobull">
<xsl:apply-templates select="//index" mode="index.mode">
<xsl:sort select="@level1"/>
<xsl:sort select="@level2"/>
<xsl:sort select="@level3"/>
<xsl:sort select="@level4"/>
</xsl:apply-templates>
</ul>
</div>
</xsl:template><xsl:template match="index" mode="index.mode">
<xsl:choose>
<xsl:when test="@level2 and not(@level3)">
<li>
<b><xsl:value-of select="@level1"/>,</b>
<ul class="nobull">
<li>
<xsl:value-of select="@level2"/>:
<a href="#{generate-id(.)}"> Link</a>
</li>
</ul>
</li>
</xsl:when>
<xsl:when test="@level3 and not(@level4)">
<li>
<b><xsl:value-of select="@level1"/>,</b>
<ul class="nobull">
<li>
<xsl:value-of select="@level2"/>,
<ul class="nobull">
<li>
<xsl:value-of select="@level3"/>:
<a href="#{generate-id(.)}"> Link</a>
</li>
</ul>
</li>
</ul>
</li>
</xsl:when>
<xsl:when test="@level4">
<li>
<b><xsl:value-of select="@level1"/>,</b>
<ul class="nobull">
<li>
<xsl:value-of select="@level2"/>,
<ul class="nobull">
<li>
<xsl:value-of select="@level3"/>,
<ul class="nobull">
<xsl:value-of select="@level4"/>:
<a href="#{generate-id(.)}"> Link</a>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</xsl:when>
<xsl:otherwise>
<li>
<b><xsl:value-of select="@level1"/>:</b>
<a href="#{generate-id(.)}"> Link</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:template></xsl:stylesheet> Kirk V. Hastings Digital Publishing Specialist Library Systems Office 386 Doe Annex University of California Berkeley, CA, 94720 khasting@xxxxxxxxxxxxxxxxxxxx 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








