-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use a function similar to group-index to sort secundary and tertiary indexterms #50
Open
hryom
wants to merge
6
commits into
docbook:master
Choose a base branch
from
hryom:sorting_in_kozek_index
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5c60289
use a function similar to group-index to sort secundary and tertiary …
hryom 188bc11
missing namespace declarations added
hryom f224743
copy kosek indexterm templates to autoidx-kosek stylesheet files
hryom af40afe
Revert "missing namespace declarations added"
hryom 24275b4
reverse kosek pollution of autoidx
hryom 7c41373
use kosek mode on copied templates
hryom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,4 +150,157 @@ | |
match="d:indexterm" | ||
use="i:group-index(&primary;)"/> | ||
|
||
<func:function name="i:term-index"> | ||
<xsl:param name="term"/> | ||
|
||
<xsl:variable name="letters-rtf"> | ||
<xsl:variable name="lang"> | ||
<xsl:call-template name="l10n.language"/> | ||
</xsl:variable> | ||
|
||
<xsl:variable name="local.l10n.letters" | ||
select="($local.l10n.xml//l:i18n/l:l10n[@language=$lang]/l:letters)[1]"/> | ||
|
||
<xsl:for-each select="$l10n.xml"> | ||
<xsl:variable name="l10n.letters" | ||
select="document(key('l10n-lang', $lang)/@href)/l:l10n/l:letters[1]"/> | ||
|
||
<xsl:choose> | ||
<xsl:when test="count($local.l10n.letters) > 0"> | ||
<xsl:copy-of select="$local.l10n.letters"/> | ||
</xsl:when> | ||
<xsl:when test="count($l10n.letters) > 0"> | ||
<xsl:copy-of select="$l10n.letters"/> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:message> | ||
<xsl:text>No "</xsl:text> | ||
<xsl:value-of select="$lang"/> | ||
<xsl:text>" localization of index grouping letters exists</xsl:text> | ||
<xsl:choose> | ||
<xsl:when test="$lang = 'en'"> | ||
<xsl:text>.</xsl:text> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:text>; using "en".</xsl:text> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:message> | ||
<xsl:copy-of select="document(key('l10n-lang', 'en'))/l:l10n/l:letters[1]"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:for-each> | ||
</xsl:variable> | ||
|
||
<xsl:variable name="letters" select="exslt:node-set($letters-rtf)/*"/> | ||
|
||
<xsl:variable name="normalize.sort"> | ||
<xsl:variable name="lang"> | ||
<xsl:call-template name="l10n.language"/> | ||
</xsl:variable> | ||
|
||
<xsl:variable name="local.l10n.normalize.sort" select="($local.l10n.xml//l:i18n/l:l10n[@language=$lang]/l:gentext[starts-with(@key, 'normalize.sort')])"/> | ||
|
||
<xsl:for-each select="$l10n.xml"> | ||
<xsl:variable name="l10n.normalize.sort" select="document(key('l10n-lang', $lang)/@href)/l:l10n/l:gentext[starts-with(@key, 'normalize.sort')]"/> | ||
|
||
<xsl:choose> | ||
<xsl:when test="count($local.l10n.normalize.sort) > 0"> | ||
<xsl:copy-of select="$local.l10n.normalize.sort"/> | ||
</xsl:when> | ||
<xsl:when test="count($l10n.normalize.sort) > 0"> | ||
<xsl:copy-of select="$l10n.normalize.sort"/> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:message> | ||
<xsl:text>No "</xsl:text> | ||
<xsl:value-of select="$lang"/> | ||
<xsl:text>" normalizing translate strings exists</xsl:text> | ||
<xsl:choose> | ||
<xsl:when test="$lang = 'en'"> | ||
<xsl:text>.</xsl:text> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:text>; using "en".</xsl:text> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:message> | ||
<xsl:copy-of select="document(key('l10n-lang', 'en')/@href)/l:l10n/l:gentext[starts-with(@key, 'normalize.sort.input')]"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:for-each> | ||
</xsl:variable> | ||
|
||
<xsl:variable name="normalize.sort.input"> | ||
<xsl:value-of select="exslt:node-set($normalize.sort)/l:gentext[@key = 'normalize.sort.input']/@text"/> | ||
</xsl:variable> | ||
<xsl:variable name="normalize.sort.output"> | ||
<xsl:value-of select="exslt:node-set($normalize.sort)/l:gentext[@key = 'normalize.sort.output']/@text"/> | ||
</xsl:variable> | ||
|
||
<xsl:variable name="term-index"> | ||
<xsl:call-template name="calculate-term-index"> | ||
<xsl:with-param name="term" select="$term"/> | ||
<xsl:with-param name="term-index" select="' '"/> | ||
<xsl:with-param name="letters" select="$letters"/> | ||
<xsl:with-param name="normalize.sort.input" select="$normalize.sort.input"/> | ||
<xsl:with-param name="normalize.sort.output" select="$normalize.sort.output"/> | ||
</xsl:call-template> | ||
</xsl:variable> | ||
|
||
<func:result select="normalize-space($term-index)"/> | ||
</func:function> | ||
|
||
<xsl:template name="calculate-term-index"> | ||
<xsl:param name="term"/> | ||
<xsl:param name="term-index"/> | ||
<xsl:param name="letters"/> | ||
<xsl:param name="normalize.sort.input"/> | ||
<xsl:param name="normalize.sort.output"/> | ||
|
||
<xsl:variable name="firstletterinterm" select="substring($term, 1, 1)"/> | ||
<xsl:variable name="firstletterindex"> | ||
<xsl:choose> | ||
<xsl:when test="$letters/l:l[. = $firstletterinterm]/@i"> | ||
<xsl:variable name="indexnumber" select="$letters/l:l[. = $firstletterinterm]/@i"/> | ||
<xsl:if test="$indexnumber < 10"> | ||
<xsl:text>0</xsl:text> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why zero is returned if number from lookup table is smaller then 10? There are localization files using numbers <10 for normal characters. |
||
</xsl:if> | ||
<xsl:value-of select="$indexnumber"/> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:variable name="tmpc" select="translate($firstletterinterm, $normalize.sort.input, $normalize.sort.output)"/> | ||
<xsl:choose> | ||
<xsl:when test="$letters/l:l[. = $tmpc]/@i"> | ||
<xsl:variable name="indexnumber" select="$letters/l:l[. = $tmpc]/@i"/> | ||
<xsl:if test="$indexnumber < 10"> | ||
<xsl:text>0</xsl:text> | ||
</xsl:if> | ||
<xsl:value-of select="$indexnumber"/> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="$firstletterinterm"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:variable> | ||
<xsl:variable name="restofterm" select="substring-after($term, $firstletterinterm)"/> | ||
|
||
<xsl:choose> | ||
<xsl:when test="$restofterm != ''"> | ||
<xsl:call-template name="calculate-term-index"> | ||
<xsl:with-param name="term" select="$restofterm"/> | ||
<xsl:with-param name="term-index" select="concat($term-index, ' ', $firstletterindex)"/> | ||
<xsl:with-param name="letters" select="$letters"/> | ||
<xsl:with-param name="normalize.sort.input" select="$normalize.sort.input"/> | ||
<xsl:with-param name="normalize.sort.output" select="$normalize.sort.output"/> | ||
</xsl:call-template> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="concat($term-index, ' ', $firstletterindex)"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In some languages two characters are treated as one letter for purposes of sorting, for example "ch" in Czech. I don't think your code can handle this situation.