[yelp-xsl] dita: Common templates for navtitle/shortdesc, more cases
- From: Shaun McCance <shaunm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp-xsl] dita: Common templates for navtitle/shortdesc, more cases
- Date: Sun, 11 Nov 2012 04:39:10 +0000 (UTC)
commit aae6889a55f8c7171bb0781d60291a9681fe5ac9
Author: Shaun McCance <shaunm gnome org>
Date: Sat Nov 10 23:38:27 2012 -0500
dita: Common templates for navtitle/shortdesc, more cases
xslt/dita/common/dita-ref.xsl | 59 +++++++++++++++
xslt/dita/common/dita-selectors.mod | 17 ++++-
xslt/dita/html/dita2html-inline.xsl | 6 ++
xslt/dita/html/dita2html-topic.xsl | 137 +++++++++++++----------------------
4 files changed, 133 insertions(+), 86 deletions(-)
---
diff --git a/xslt/dita/common/dita-ref.xsl b/xslt/dita/common/dita-ref.xsl
index b06dd27..cfedddb 100644
--- a/xslt/dita/common/dita-ref.xsl
+++ b/xslt/dita/common/dita-ref.xsl
@@ -50,6 +50,11 @@ when creating output files from DITA topics.
<xsl:key name="dita.id.key" match="*[ id][not(self::&topic_topic_all;)]"
use="concat(ancestor-or-self::&topic_topic_all;[1]/@id, '/', @id)"/>
+
+<xsl:template mode="dita.ref.content.mode" match="* | text()">
+ <xsl:value-of select="."/>
+</xsl:template>
+
<xsl:template name="dita.id">
<xsl:param name="node" select="."/>
<xsl:choose>
@@ -203,4 +208,58 @@ when creating output files from DITA topics.
<xsl:param name="href" select="$node/@href"/>
</xsl:template>
+<xsl:template name="dita.ref.topicref.navtitle">
+ <xsl:param name="node" select="."/>
+ <xsl:param name="href" select="$node/@href"/>
+ <xsl:param name="base" select="$dita.map.base"/>
+ <xsl:choose>
+ <xsl:when test="$node[self::&map_map;]/&topic_booktitle;/&topic_mainbooktitle;">
+ <xsl:apply-templates mode="dita.ref.content.mode"
+ select="$node/&topic_booktitle;/&topic_mainbooktitle;/node()"/>
+ </xsl:when>
+ <xsl:when test="$node[self::&map_map;]">
+ <xsl:apply-templates mode="dita.ref.content.mode" select="$node/&topic_title;/node()"/>
+ </xsl:when>
+ <xsl:when test="$node/&map_topicmeta;/&topic_navtitle;">
+ <xsl:apply-templates mode="dita.ref.content.mode"
+ select="$node/&map_topicmeta;/&topic_navtitle;/node()"/>
+ </xsl:when>
+ <xsl:when test="$node/@navtitle">
+ <xsl:value-of select="$node/@navtitle"/>
+ </xsl:when>
+ <xsl:when test="$href != ''">
+ <xsl:variable name="topic" select="document($href, $base)/&topic_topic_all;"/>
+ <xsl:choose>
+ <xsl:when test="$topic/&topic_titlealts;/&topic_navtitle;">
+ <xsl:apply-templates mode="dita.ref.content.mode"
+ select="$topic/&topic_titlealts;/&topic_navtitle;/node()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="dita.ref.content.mode"
+ select="$topic/&topic_title_all;/node()"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="dita.ref.topicref.shortdesc">
+ <xsl:param name="node" select="."/>
+ <xsl:param name="href" select="$node/@href"/>
+ <xsl:param name="base" select="$dita.map.base"/>
+ <xsl:choose>
+ <xsl:when test="$node/&map_topicmeta;/&topic_shortdesc;">
+ <xsl:apply-templates mode="dita.ref.content.mode"
+ select="$node/&map_topicmeta;/&topic_shortdesc;/node()"/>
+ </xsl:when>
+ <xsl:when test="$href != ''">
+ <xsl:variable name="topic" select="document($href, $base)/&topic_topic_all;"/>
+ <xsl:if test="$topic/&topic_shortdesc;">
+ <xsl:apply-templates mode="dita.ref.content.mode"
+ select="$topic/&topic_shortdesc;/node()"/>
+ </xsl:if>
+ </xsl:when>
+ </xsl:choose>
+</xsl:template>
+
</xsl:stylesheet>
diff --git a/xslt/dita/common/dita-selectors.mod b/xslt/dita/common/dita-selectors.mod
index 88764c5..1910828 100644
--- a/xslt/dita/common/dita-selectors.mod
+++ b/xslt/dita/common/dita-selectors.mod
@@ -35,6 +35,11 @@ map/map
starts-with(@class, '- map/map ')]">
<!-- ===========================================================================
+map/topicmeta
+-->
+<!ENTITY map_topicmeta "*[name(.) = 'topicmeta' or starts-with(@class, '- map/topicmeta ')]">
+
+<!-- ===========================================================================
map/topicref
-->
<!ENTITY map_topicref "*[
@@ -42,7 +47,7 @@ map/topicref
starts-with(@class, '- map/topicref ')]">
<!-- ===========================================================================
-topic/desc
+topic/alt
-->
<!ENTITY topic_alt "*[name(.) = 'alt' or starts-with(@class, '- topic/alt ')]">
@@ -181,6 +186,11 @@ topic/linktext
<!ENTITY topic_linktext "*[name(.) = 'linktext' or starts-with(@class, '- topic/linktext ')]">
<!-- ===========================================================================
+topic/navtitle
+-->
+<!ENTITY topic_navtitle "*[name(.) = 'navtitle' or starts-with(@class, '- topic/navtitle ')]">
+
+<!-- ===========================================================================
topic/note
-->
<!ENTITY topic_note "*[name(.) = 'note' or starts-with(@class, '- topic/note ')]">
@@ -366,6 +376,11 @@ topic/title
]">
<!-- ===========================================================================
+topic/titlealts
+-->
+<!ENTITY topic_titlealts "*[name(.) = 'titlealts' or starts-with(@class, '- topic/titlealts ')]">
+
+<!-- ===========================================================================
topic/topic
-->
<!ENTITY topic_topic "*[
diff --git a/xslt/dita/html/dita2html-inline.xsl b/xslt/dita/html/dita2html-inline.xsl
index 16bd8c0..7e80cd0 100644
--- a/xslt/dita/html/dita2html-inline.xsl
+++ b/xslt/dita/html/dita2html-inline.xsl
@@ -32,6 +32,12 @@ DITA to HTML - Inlines
REMARK: Describe this module
-->
+
+<xsl:template mode="dita.ref.content.mode" match="*">
+ <xsl:apply-templates mode="dita2html.topic.mode" select="."/>
+</xsl:template>
+
+
<!--**==========================================================================
dita2html.span
Output an HTML #{span} element.
diff --git a/xslt/dita/html/dita2html-topic.xsl b/xslt/dita/html/dita2html-topic.xsl
index 6b4ba15..b16b1f0 100644
--- a/xslt/dita/html/dita2html-topic.xsl
+++ b/xslt/dita/html/dita2html-topic.xsl
@@ -58,11 +58,11 @@ REMARK: Describe this module
<!-- == dita2html.links.prevnext == -->
<xsl:template name="dita2html.links.prevnext">
<xsl:param name="node" select="."/>
- <xsl:variable name="prev" select="($node/parent::&map_topicref;[ href] |
+ <xsl:variable name="prev" select="($node/ancestor::&map_topicref;[ href][1] |
$node/preceding::&map_topicref;[ href][1] |
- ancestor::&map_map;[1]
+ $node/ancestor::&map_map;[1]
)[last()]"/>
- <xsl:variable name="next" select="($node/&map_topicref;[ href] |
+ <xsl:variable name="next" select="($node//&map_topicref;[ href][1] |
$node/following::&map_topicref;[ href]
)[1]"/>
<div class="links nextlinks">
@@ -88,19 +88,9 @@ REMARK: Describe this module
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="title">
- <xsl:choose>
- <xsl:when test="$prev[self::&map_map;]">
- <xsl:apply-templates mode="dita2html.topic.mode"
- select="$prev/&topic_title;/node()"/>
- </xsl:when>
- <xsl:when test="$prev/@navtitle">
- <xsl:value-of select="$prev/@navtitle"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates mode="dita2html.topic.mode"
- select="document($prev/@href, $dita.map.base)/&topic_topic_all;/&topic_title_all;/node()"/>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:call-template name="dita.ref.topicref.navtitle">
+ <xsl:with-param name="node" select="$prev"/>
+ </xsl:call-template>
</xsl:attribute>
<xsl:call-template name="l10n.gettext">
<xsl:with-param name="msgid" select="'Previous'"/>
@@ -123,15 +113,9 @@ REMARK: Describe this module
</xsl:call-template>
</xsl:attribute>
<xsl:attribute name="title">
- <xsl:choose>
- <xsl:when test="$next/@navtitle">
- <xsl:value-of select="$next/@navtitle"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates mode="dita2html.topic.mode"
- select="document($next/@href, $dita.map.base)/&topic_topic_all;/&topic_title_all;/node()"/>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:call-template name="dita.ref.topicref.navtitle">
+ <xsl:with-param name="node" select="$next"/>
+ </xsl:call-template>
</xsl:attribute>
<xsl:call-template name="l10n.gettext">
<xsl:with-param name="msgid" select="'Next'"/>
@@ -142,27 +126,14 @@ REMARK: Describe this module
</xsl:template>
-<!-- == map == -->
-
-<!-- = map % html.output.after.mode = -->
-<xsl:template mode="html.output.after.mode" match="/&map_map;">
- <xsl:for-each select="//&map_topicref;[ href]">
- <xsl:call-template name="html.output">
- <xsl:with-param name="href">
- <xsl:call-template name="dita.ref.href.target"/>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:for-each>
-</xsl:template>
+<!-- == dita2html.links.topic == -->
<xsl:template name="dita2html.links.topic">
- <xsl:param name="base" select="."/>
<xsl:param name="source" select="."/>
<xsl:if test="$source/&map_topicref;">
<div class="links sectionlinks" role="navigation">
<ul>
<xsl:apply-templates mode="dita2html.links.topic.mode" select="$source/&map_topicref;">
- <xsl:with-param name="base" select="$base"/>
<xsl:with-param name="source" select="$source"/>
</xsl:apply-templates>
</ul>
@@ -172,16 +143,7 @@ REMARK: Describe this module
<xsl:template mode="dita2html.links.topic.mode" match="*"/>
<xsl:template mode="dita2html.links.topic.mode" match="&map_topicref;">
- <xsl:param name="base" select="."/>
- <xsl:param name="source"/>
- <xsl:variable name="uri">
- <xsl:for-each select="str:split($source/@href, '/')">
- <xsl:if test="position() != last()">
- <xsl:text>../</xsl:text>
- </xsl:if>
- </xsl:for-each>
- <xsl:value-of select="@href"/>
- </xsl:variable>
+ <xsl:param name="source" select=".."/>
<li class="links">
<xsl:choose>
<xsl:when test="@href">
@@ -194,27 +156,20 @@ REMARK: Describe this module
</xsl:for-each>
<xsl:call-template name="dita.ref.href.target"/>
</xsl:attribute>
- <xsl:choose>
- <xsl:when test="@navtitle">
- <xsl:value-of select="@navtitle"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates mode="dita2html.topic.mode"
- select="document($uri, $base)/&topic_topic_all;/&topic_title_all;/node()"/>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:call-template name="dita.ref.topicref.navtitle"/>
</a>
- <xsl:variable name="desc" select="document($uri, $base)/&topic_topic_all;/&topic_shortdesc;"/>
- <xsl:if test="$desc">
+ <xsl:variable name="desc">
+ <xsl:call-template name="dita.ref.topicref.shortdesc"/>
+ </xsl:variable>
+ <xsl:if test="$desc != ''">
<span class="desc">
<xsl:text> — </xsl:text>
- <xsl:apply-templates mode="dita2html.topic.mode" select="yelp:dita.ref.conref($desc)/node()"/>
+ <xsl:copy-of select="$desc"/>
</span>
</xsl:if>
</xsl:when>
<xsl:otherwise>
- <!-- FIXME -->
- <xsl:value-of select="@navtitle"/>
+ <xsl:call-template name="dita.ref.topicref.navtitle"/>
<xsl:if test="&map_topicref;">
<ul>
<xsl:apply-templates mode="dita2html.links.topic.mode" select="&map_topicref;">
@@ -228,6 +183,31 @@ REMARK: Describe this module
</xsl:template>
+<!-- == map == -->
+
+<!-- = map % html.output.after.mode = -->
+<xsl:template mode="html.output.after.mode" match="/&map_map;">
+ <xsl:for-each select="//&map_topicref;[ href]">
+ <xsl:call-template name="html.output">
+ <xsl:with-param name="href">
+ <xsl:call-template name="dita.ref.href.target"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:for-each>
+</xsl:template>
+
+<!-- = map % html.title.mode = -->
+<xsl:template mode="html.title.mode" match="&map_map;">
+ <xsl:choose>
+ <xsl:when test="&topic_booktitle;/&topic_mainbooktitle;">
+ <xsl:value-of select="&topic_booktitle;/&topic_mainbooktitle;"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="&topic_title_all;"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
<!-- = map % html.body.mode = -->
<xsl:template mode="html.body.mode" match="&map_map;">
<xsl:call-template name="dita2html.links.prevnext"/>
@@ -242,7 +222,7 @@ REMARK: Describe this module
<xsl:call-template name="dita.id"/>
<xsl:call-template name="html.lang.attrs"/>
<xsl:call-template name="dita2html.links.topic">
- <xsl:with-param name="base" select="$dita.map.base"/>
+ <xsl:with-param name="source" select="."/>
</xsl:call-template>
</div>
<xsl:call-template name="dita2html.links.prevnext"/>
@@ -286,16 +266,9 @@ REMARK: Describe this module
<xsl:with-param name="href" select="'index'"/>
</xsl:call-template>
</xsl:attribute>
- <xsl:choose>
- <xsl:when test="/&map_map;/&topic_booktitle;">
- <xsl:apply-templates mode="dita2html.topic.mode"
- select="/&map_map;/&topic_title_all;/&topic_mainbooktitle;/node()"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates mode="dita2html.topic.mode"
- select="/&map_map;/&topic_title_all;/node()"/>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:call-template name="dita.ref.topicref.navtitle">
+ <xsl:with-param name="node" select="/&map_map;"/>
+ </xsl:call-template>
</a>
<xsl:value-of select="$sep"/>
<xsl:for-each select="ancestor::&map_topicref;">
@@ -310,19 +283,11 @@ REMARK: Describe this module
</xsl:for-each>
<xsl:call-template name="dita.ref.href.target"/>
</xsl:attribute>
- <xsl:choose>
- <xsl:when test="@navtitle">
- <xsl:value-of select="@navtitle"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates mode="dita2html.topic.mode"
- select="document(@href, $dita.map.base)/&topic_topic_all;/&topic_title_all;/node()"/>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:call-template name="dita.ref.topicref.navtitle"/>
</a>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="@navtitle"/>
+ <xsl:call-template name="dita.ref.topicref.navtitle"/>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$sep"/>
@@ -457,7 +422,9 @@ th, td { border: solid 1px; }
<xsl:apply-templates mode="dita2html.topic.mode" select="../&topic_shortdesc;"/>
<xsl:apply-templates mode="dita2html.topic.mode" select="$conref/node()"/>
</div>
- <xsl:call-template name="dita2html.links.topic"/>
+ <xsl:call-template name="dita2html.links.topic">
+ <xsl:with-param name="source" select="$topicref"/>
+ </xsl:call-template>
</div>
</xsl:template>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]