| 1 |
<?xml version="1.0"?> |
|---|
| 2 |
<!DOCTYPE xsl:stylesheet [ |
|---|
| 3 |
|
|---|
| 4 |
<!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'"> |
|---|
| 5 |
<!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"> |
|---|
| 6 |
|
|---|
| 7 |
<!ENTITY primary 'normalize-space(concat(primary/@sortas, primary[not(@sortas)]))'> |
|---|
| 8 |
<!ENTITY secondary 'normalize-space(concat(secondary/@sortas, secondary[not(@sortas)]))'> |
|---|
| 9 |
<!ENTITY tertiary 'normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas)]))'> |
|---|
| 10 |
|
|---|
| 11 |
<!ENTITY sep '" "'> |
|---|
| 12 |
<!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node()) |
|---|
| 13 |
and ($role = @role or $type = @type or |
|---|
| 14 |
(string-length($role) = 0 and string-length($type) = 0))'> |
|---|
| 15 |
]> |
|---|
| 16 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|---|
| 17 |
xmlns:fo="http://www.w3.org/1999/XSL/Format" |
|---|
| 18 |
version="1.0" |
|---|
| 19 |
xmlns:func="http://exslt.org/functions" |
|---|
| 20 |
exclude-result-prefixes="i" |
|---|
| 21 |
xmlns:i="urn:cz-kosek:functions:index"> |
|---|
| 22 |
|
|---|
| 23 |
<!-- ******************************************************************** |
|---|
| 24 |
$Id: autoidx-ng.xsl,v 1.4 2004/08/26 07:50:09 kosek Exp $ |
|---|
| 25 |
******************************************************************** |
|---|
| 26 |
|
|---|
| 27 |
This file is part of the DocBook XSL Stylesheet distribution. |
|---|
| 28 |
See ../README or http://docbook.sf.net/ for copyright |
|---|
| 29 |
and other information. |
|---|
| 30 |
|
|---|
| 31 |
******************************************************************** --> |
|---|
| 32 |
|
|---|
| 33 |
<xsl:include href="../common/autoidx-ng.xsl"/> |
|---|
| 34 |
|
|---|
| 35 |
<!-- Modified original code is using index group codes instead of just first letter |
|---|
| 36 |
to gain better grouping --> |
|---|
| 37 |
<xsl:template name="generate-index"> |
|---|
| 38 |
<xsl:param name="scope" select="(ancestor::book|/)[last()]"/> |
|---|
| 39 |
|
|---|
| 40 |
<xsl:variable name="role"> |
|---|
| 41 |
<xsl:if test="$index.on.role != 0"> |
|---|
| 42 |
<xsl:value-of select="@role"/> |
|---|
| 43 |
</xsl:if> |
|---|
| 44 |
</xsl:variable> |
|---|
| 45 |
|
|---|
| 46 |
<xsl:variable name="type"> |
|---|
| 47 |
<xsl:if test="$index.on.type != 0"> |
|---|
| 48 |
<xsl:value-of select="@type"/> |
|---|
| 49 |
</xsl:if> |
|---|
| 50 |
</xsl:variable> |
|---|
| 51 |
|
|---|
| 52 |
<xsl:variable name="terms" |
|---|
| 53 |
select="//indexterm[count(.|key('group-code', |
|---|
| 54 |
i:group-index(&primary;))[&scope;][1]) = 1 |
|---|
| 55 |
and not(@class = 'endofrange')]"/> |
|---|
| 56 |
|
|---|
| 57 |
<div class="index"> |
|---|
| 58 |
<xsl:apply-templates select="$terms" mode="index-div"> |
|---|
| 59 |
<xsl:with-param name="scope" select="$scope"/> |
|---|
| 60 |
<xsl:with-param name="role" select="$role"/> |
|---|
| 61 |
<xsl:with-param name="type" select="$type"/> |
|---|
| 62 |
<xsl:sort select="i:group-index(&primary;)" data-type="number"/> |
|---|
| 63 |
</xsl:apply-templates> |
|---|
| 64 |
</div> |
|---|
| 65 |
</xsl:template> |
|---|
| 66 |
|
|---|
| 67 |
<xsl:template match="indexterm" mode="index-div"> |
|---|
| 68 |
<xsl:param name="scope" select="."/> |
|---|
| 69 |
<xsl:param name="role" select="''"/> |
|---|
| 70 |
<xsl:param name="type" select="''"/> |
|---|
| 71 |
|
|---|
| 72 |
<xsl:variable name="key" |
|---|
| 73 |
select="i:group-index(&primary;)"/> |
|---|
| 74 |
|
|---|
| 75 |
<xsl:variable name="lang"> |
|---|
| 76 |
<xsl:call-template name="l10n.language"/> |
|---|
| 77 |
</xsl:variable> |
|---|
| 78 |
|
|---|
| 79 |
<xsl:if test="key('group-code', $key)[&scope;] |
|---|
| 80 |
[count(.|key('primary', &primary;)[&scope;][1]) = 1]"> |
|---|
| 81 |
<div class="indexdiv"> |
|---|
| 82 |
<h3> |
|---|
| 83 |
<xsl:value-of select="i:group-letter($key)"/> |
|---|
| 84 |
</h3> |
|---|
| 85 |
<dl> |
|---|
| 86 |
<xsl:apply-templates select="key('group-code', $key)[&scope;] |
|---|
| 87 |
[count(.|key('primary', &primary;)[&scope;][1])=1]" |
|---|
| 88 |
mode="index-primary"> |
|---|
| 89 |
<xsl:sort select="&primary;" lang="{$lang}"/> |
|---|
| 90 |
<xsl:with-param name="scope" select="$scope"/> |
|---|
| 91 |
<xsl:with-param name="role" select="$role"/> |
|---|
| 92 |
<xsl:with-param name="type" select="$type"/> |
|---|
| 93 |
</xsl:apply-templates> |
|---|
| 94 |
</dl> |
|---|
| 95 |
</div> |
|---|
| 96 |
</xsl:if> |
|---|
| 97 |
</xsl:template> |
|---|
| 98 |
|
|---|
| 99 |
</xsl:stylesheet> |
|---|