1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
2 | <xsl:stylesheet version="1.0"
|
---|
3 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
4 | xmlns:java="http://xml.apache.org/xalan/java"
|
---|
5 | xmlns:util="ExternalRef" extension-element-prefixes="util">
|
---|
6 |
|
---|
7 | <xsl:template match="CrossRef">
|
---|
8 | <xsl:variable name="ref" select="@ref"/>
|
---|
9 | <xsl:if test="@external">
|
---|
10 | <xsl:variable name="external" select="@external"/>
|
---|
11 | <!--<a><xsl:attribute name="href"><xsl:value-of select="java:getRef($util, '@external', '@lang', '@target', '$ref')"/></xsl:attribute></a>-->
|
---|
12 | <a><xsl:attribute name="href"><xsl:value-of select="concat(@external, '_', @lang, '_all.html#', @target, '_', @ref)"/></xsl:attribute><xsl:value-of select="util:getRef($external, @lang, @target, $ref)"/></a>
|
---|
13 | </xsl:if>
|
---|
14 |
|
---|
15 | <xsl:variable name="current_chapter" select="ancestor-or-self::Chapter[position()=1]/@id"/>
|
---|
16 |
|
---|
17 | <xsl:variable name="target_chapter">
|
---|
18 | <xsl:choose>
|
---|
19 | <xsl:when test="@target='Figure'"><xsl:value-of select="//Figure[@id=$ref]/ancestor-or-self::Chapter[position()=1]/@id"/></xsl:when>
|
---|
20 | <xsl:when test="@target='Table'"><xsl:value-of select="//Table[@id=$ref]/ancestor-or-self::Chapter[position()=1]/@id"/></xsl:when>
|
---|
21 | <xsl:when test="@target='Chapter'"><xsl:value-of select="//Chapter[@id=$ref]/ancestor-or-self::Chapter[position()=1]/@id"/></xsl:when>
|
---|
22 | <xsl:when test="@target='Section'"><xsl:value-of select="//Section[@id=$ref]/ancestor-or-self::Chapter[position()=1]/@id"/></xsl:when>
|
---|
23 | <xsl:when test="@target='Subsection'"><xsl:value-of select="//Subsection[@id=$ref]/ancestor-or-self::Chapter[position()=1]/@id"/></xsl:when>
|
---|
24 | </xsl:choose>
|
---|
25 | </xsl:variable>
|
---|
26 |
|
---|
27 | <a>
|
---|
28 | <xsl:attribute name="href">
|
---|
29 | <xsl:if test="not($current_chapter=$target_chapter)"><xsl:value-of select="concat('Chapter_', $target_chapter, '.htm#', @target, '_', @ref)"/></xsl:if>
|
---|
30 | <xsl:if test="$current_chapter=$target_chapter"><xsl:value-of select="concat('#', @target, '_', @ref)"/></xsl:if>
|
---|
31 | </xsl:attribute>
|
---|
32 | <xsl:choose>
|
---|
33 | <xsl:when test="@target='Figure'"><xsl:apply-templates select="//Figure[@id=$ref]" mode="ref"/></xsl:when>
|
---|
34 | <xsl:when test="@target='Table'"><xsl:apply-templates select="//Table[@id=$ref]" mode="ref"/></xsl:when>
|
---|
35 | <xsl:when test="@target='Chapter'"><xsl:apply-templates select="//Chapter[@id=$ref]" mode="ref"/></xsl:when>
|
---|
36 | <xsl:when test="@target='Section'"><xsl:apply-templates select="//Section[@id=$ref]" mode="ref"/></xsl:when>
|
---|
37 | <xsl:when test="@target='Subsection'"><xsl:apply-templates select="//Subsection[@id=$ref]" mode="ref"/></xsl:when>
|
---|
38 | </xsl:choose>
|
---|
39 | </a>
|
---|
40 | </xsl:template>
|
---|
41 |
|
---|
42 | <!--
|
---|
43 | <xsl:template match="FootnoteList">
|
---|
44 | <xsl:for-each select="Footnote">
|
---|
45 | <xsl:variable name="number">
|
---|
46 | <xsl:apply-templates select="//FootnoteRef[@id=@id]" mode="getid"/>
|
---|
47 | </xsl:variable>
|
---|
48 |
|
---|
49 | <a name="fn{@id}"/><a href="#fnref{@id}">[<xsl:value-of select="$number"/>]</a>
|
---|
50 | <xsl:apply-templates/>
|
---|
51 | <br/>
|
---|
52 | </xsl:for-each>
|
---|
53 | </xsl:template>-->
|
---|
54 |
|
---|
55 | <xsl:template match="FootnoteRef">
|
---|
56 | <a name="fnref{@id}"/><a href="#fn{@id}">[<xsl:number count="FootnoteRef" level="any" from="Chapter"/>]</a>
|
---|
57 | </xsl:template>
|
---|
58 |
|
---|
59 | <xsl:template match="FootnoteRef" mode="getid">
|
---|
60 | <xsl:number count="FootnoteRef" level="any" from="Chapter"/>
|
---|
61 | </xsl:template>
|
---|
62 |
|
---|
63 | </xsl:stylesheet>
|
---|