summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xslt/mallard/common/mal-link.xsl31
-rw-r--r--xslt/mallard/html/mal2html-page.xsl122
-rw-r--r--xslt/mallard/html/mal2html.xsl4
-rw-r--r--xslt/mallard/utils/mal2cache.xsl2
4 files changed, 42 insertions, 117 deletions
diff --git a/xslt/mallard/common/mal-link.xsl b/xslt/mallard/common/mal-link.xsl
index 63b228c..850ef2f 100644
--- a/xslt/mallard/common/mal-link.xsl
+++ b/xslt/mallard/common/mal-link.xsl
@@ -25,6 +25,15 @@ Mallard Links
-->
+<!--@@==========================================================================
+mal.cache.file
+The location of the cache file
+-->
+<xsl:param name="mal.cache.file"/>
+<xsl:variable name="mal.cache" select="document($mal.cache.file)"/>
+<xsl:key name="mal.cache.key" match="mal:page | mal:section" use="@id"/>
+
+
<!--**==========================================================================
mal.link.content
Generates the content for a #{link} element
@@ -40,7 +49,7 @@ $href: The #{href} attribute of ${link}
<xsl:when test="contains($xref, '/')">
<!--
This is a link to another document, which we don't handle in these
- stylesheets. Extensions such like library or yelp should override
+ stylesheets. Extensions such as library or yelp should override
this template to provide this functionality.
-->
<xsl:choose>
@@ -53,19 +62,11 @@ $href: The #{href} attribute of ${link}
</xsl:choose>
</xsl:when>
<xsl:otherwise>
- <xsl:variable name="linkid">
- <xsl:choose>
- <xsl:when test="contains($xref, '#')">
- <xsl:value-of select="$xref"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat($xref, '#', $xref)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:apply-templates mode="mal.link.content.mode"
- select="key('cache_key', $linkid)
- /mal:info/mal:title[@type = 'link']/node()"/>
+ <xsl:for-each select="$mal.cache">
+ <xsl:apply-templates mode="mal.link.content.mode"
+ select="key('mal.cache.key', $xref)
+ /mal:info/mal:title[@type = 'link']/node()"/>
+ </xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
@@ -102,7 +103,7 @@ $href: The #{href} attribute of ${link}
<xsl:when test="contains($xref, '/')">
<!--
This is a link to another document, which we don't handle in these
- stylesheets. Extensions such like library or yelp should override
+ stylesheets. Extensions such as library or yelp should override
this template to provide this functionality.
-->
<xsl:value-of select="$href"/>
diff --git a/xslt/mallard/html/mal2html-page.xsl b/xslt/mallard/html/mal2html-page.xsl
index f4908ac..3d2a73b 100644
--- a/xslt/mallard/html/mal2html-page.xsl
+++ b/xslt/mallard/html/mal2html-page.xsl
@@ -70,9 +70,8 @@ REMARK: Describe this template
<xsl:variable name="pagelinks"
select="$node/mal:info/mal:link[@type = 'topic']"/>
<!-- FIXME: // selectors are slow -->
- <!-- FIXME: exclude $pagelinks from $guidelinks -->
<xsl:variable name="guidelinks"
- select="$cache//*[mal:info/mal:link[@type = 'guide'][@xref = $id]][not(@id = $pagelinks/@xref)]"/>
+ select="$mal.cache//*[mal:info/mal:link[@type = 'guide'][@xref = $id]][not(@id = $pagelinks/@xref)]"/>
<xsl:if test="$pagelinks or $guidelinks">
<div class="pagelinks">
<xsl:choose>
@@ -81,20 +80,11 @@ REMARK: Describe this template
<table class="twocolumn"><tr>
<td class="twocolumnleft">
<xsl:for-each select="$pagelinks[position() &lt;= $coltot]">
- <xsl:variable name="linkid">
- <xsl:choose>
- <xsl:when test="contains(@xref, '#')">
- <xsl:value-of select="@xref"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat(@xref, '#', @xref)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:for-each select="$cache">
+ <xsl:variable name="xref" select="@xref"/>
+ <xsl:for-each select="$mal.cache">
<xsl:call-template name="mal2html.page.pagelink">
<xsl:with-param name="source" select="$node"/>
- <xsl:with-param name="target" select="key('cache_key', $linkid)"/>
+ <xsl:with-param name="target" select="key('mal.cache.key', $xref)"/>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>
@@ -114,20 +104,11 @@ REMARK: Describe this template
</td>
<td class="twocolumnright">
<xsl:for-each select="$pagelinks[position() &gt; $coltot]">
- <xsl:variable name="linkid">
- <xsl:choose>
- <xsl:when test="contains(@xref, '#')">
- <xsl:value-of select="@xref"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat(@xref, '#', @xref)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:for-each select="$cache">
+ <xsl:variable name="xref" select="@xref"/>
+ <xsl:for-each select="$mal.cache">
<xsl:call-template name="mal2html.page.pagelink">
<xsl:with-param name="source" select="$node"/>
- <xsl:with-param name="target" select="key('cache_key', $linkid)"/>
+ <xsl:with-param name="target" select="key('mal.cache.key', $xref)"/>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>
@@ -149,20 +130,11 @@ REMARK: Describe this template
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$pagelinks">
- <xsl:variable name="linkid">
- <xsl:choose>
- <xsl:when test="contains(@xref, '#')">
- <xsl:value-of select="@xref"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat(@xref, '#', @xref)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:for-each select="$cache">
+ <xsl:variable name="xref" select="@xref"/>
+ <xsl:for-each select="$mal.cache">
<xsl:call-template name="mal2html.page.pagelink">
<xsl:with-param name="source" select="$node"/>
- <xsl:with-param name="target" select="key('cache_key', $linkid)"/>
+ <xsl:with-param name="target" select="key('mal.cache.key', $xref)"/>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>
@@ -195,40 +167,18 @@ REMARK: Describe this template
<xsl:template name="mal2html.page.pagelink">
<xsl:param name="source" select="."/>
<xsl:param name="target"/>
- <xsl:variable name="xref">
- <xsl:choose>
- <xsl:when test="$target/self::mal:section">
- <xsl:value-of select="$target/ancestor::mal:page[1]/@id"/>
- <xsl:text>#</xsl:text>
- <xsl:value-of select="$target/@id"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$target/@id"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="linkid">
- <xsl:choose>
- <xsl:when test="contains($xref, '#')">
- <xsl:value-of select="$xref"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat($xref, '#', $xref)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
<a>
<xsl:attribute name="href">
<xsl:call-template name="mal.link.target">
<xsl:with-param name="link" select="$source"/>
- <xsl:with-param name="xref" select="$xref"/>
+ <xsl:with-param name="xref" select="$target/@id"/>
</xsl:call-template>
</xsl:attribute>
<div class="pagelink">
<div class="title">
<xsl:call-template name="mal.link.content">
<xsl:with-param name="link" select="$source"/>
- <xsl:with-param name="xref" select="$xref"/>
+ <xsl:with-param name="xref" select="$target/@id"/>
</xsl:call-template>
<xsl:if test="true()">
@@ -271,10 +221,10 @@ REMARK: Describe this template
</xsl:if>
</xsl:if>
</div>
- <xsl:variable name="desc" select="key('cache_key', $linkid)/mal:info/mal:desc[1]"/>
- <xsl:if test="$desc">
+ <xsl:if test="$target/mal:info/mal:desc">
<div class="desc">
- <xsl:apply-templates mode="mal2html.inline.mode" select="$desc/node()"/>
+ <xsl:apply-templates mode="mal2html.inline.mode"
+ select="$target/mal:info/mal:desc[1]/node()"/>
</div>
</xsl:if>
</div>
@@ -305,11 +255,11 @@ REMARK: Describe this template
</xsl:variable>
<!-- FIXME: // is slow -->
<xsl:variable name="inlinks"
- select="$cache//*[mal:info/mal:link[@type = 'seealso'][@xref = $id]]"/>
+ select="$mal.cache//*[mal:info/mal:link[@type = 'seealso'][@xref = $id]]"/>
<xsl:variable name="outlinks"
select="$node/mal:info/mal:link[@type = 'seealso']"/>
<xsl:variable name="pagelinks"
- select="$cache//*[mal:info/mal:link[@type = 'topic'][@xref = $id]]"/>
+ select="$mal.cache//*[mal:info/mal:link[@type = 'topic'][@xref = $id]]"/>
<xsl:variable name="guidelinks"
select="$node/mal:info/mal:link[@type = 'guide']"/>
<xsl:if test="$inlinks or $outlinks or $pagelinks or $guidelinks">
@@ -332,22 +282,10 @@ REMARK: Describe this template
</xsl:for-each>
<!-- FIXME: exclude pagelinks -->
<xsl:for-each select="$guidelinks">
- <xsl:variable name="linkid">
- <xsl:choose>
- <xsl:when test="contains(@xref, '#')">
- <xsl:value-of select="@xref"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat(@xref, '#', @xref)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:for-each select="$cache">
- <xsl:call-template name="mal2html.page.pagelink">
- <xsl:with-param name="source" select="$node"/>
- <xsl:with-param name="target" select="key('cache_key', $linkid)"/>
- </xsl:call-template>
- </xsl:for-each>
+ <xsl:call-template name="mal2html.page.pagelink">
+ <xsl:with-param name="source" select="$node"/>
+ <xsl:with-param name="target" select="."/>
+ </xsl:call-template>
</xsl:for-each>
<xsl:if test="($pagelinks or $guidelinks) and ($inlinks or $outlinks)">
@@ -361,28 +299,16 @@ REMARK: Describe this template
</xsl:call-template>
</xsl:for-each>
<xsl:for-each select="$outlinks">
- <xsl:variable name="linkid">
- <xsl:choose>
- <xsl:when test="contains(@xref, '#')">
- <xsl:value-of select="@xref"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat(@xref, '#', @xref)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:for-each select="$cache">
+ <xsl:variable name="xref" select="@xref"/>
+ <xsl:for-each select="$mal.cache">
<xsl:call-template name="mal2html.page.pagelink">
<xsl:with-param name="source" select="$node"/>
- <xsl:with-param name="target" select="key('cache_key', $linkid)"/>
+ <xsl:with-param name="target" select="key('mal.cache.key', $xref)"/>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>
</div>
</div>
-
- </xsl:if>
- <xsl:if test="$inlinks or $outlinks">
</xsl:if>
</xsl:template>
diff --git a/xslt/mallard/html/mal2html.xsl b/xslt/mallard/html/mal2html.xsl
index 71685a1..9b62be9 100644
--- a/xslt/mallard/html/mal2html.xsl
+++ b/xslt/mallard/html/mal2html.xsl
@@ -41,10 +41,6 @@ REMARK: Describe this module
<xsl:include href="util.xsl"/>
<xsl:param name="mal.extension" select="'.xhtml'"/>
-<xsl:param name="mal.cache_file"/>
-<xsl:variable name="cache" select="document($mal.cache_file)"/>
-<xsl:key name="cache_key" match="*[@id]"
- use="concat(ancestor-or-self::mal:page[1]/@id, '#', @id)"/>
<!-- FIXME -->
<xsl:template match="*">
diff --git a/xslt/mallard/utils/mal2cache.xsl b/xslt/mallard/utils/mal2cache.xsl
index 0d69a78..86ba254 100644
--- a/xslt/mallard/utils/mal2cache.xsl
+++ b/xslt/mallard/utils/mal2cache.xsl
@@ -61,6 +61,8 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
<section>
<xsl:if test="@id">
<xsl:attribute name="id">
+ <xsl:value-of select="ancestor::mal:page[1]/@id"/>
+ <xsl:text>#</xsl:text>
<xsl:value-of select="@id"/>
</xsl:attribute>
</xsl:if>