[yelp-xsl] dita2html: Implement imagemap, common dita.ref.href.content
- From: Shaun McCance <shaunm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp-xsl] dita2html: Implement imagemap, common dita.ref.href.content
- Date: Tue, 27 Nov 2012 13:43:24 +0000 (UTC)
commit 0bef7f590927f53b3e6b55141bbf6a6f582d1043
Author: Shaun McCance <shaunm gnome org>
Date: Tue Nov 27 08:42:52 2012 -0500
dita2html: Implement imagemap, common dita.ref.href.content
xslt/dita/common/dita-ref.xsl | 89 +++++++++++++++++++++++++++++++++-
xslt/dita/common/dita-selectors.mod | 23 +++++++++-
xslt/dita/html/dita2html-inline.xsl | 66 +++-----------------------
xslt/dita/html/dita2html-media.xsl | 53 ++++++++++++++++++++-
4 files changed, 168 insertions(+), 63 deletions(-)
---
diff --git a/xslt/dita/common/dita-ref.xsl b/xslt/dita/common/dita-ref.xsl
index cfedddb..437b263 100644
--- a/xslt/dita/common/dita-ref.xsl
+++ b/xslt/dita/common/dita-ref.xsl
@@ -120,8 +120,14 @@ when creating output files from DITA topics.
<xsl:template name="dita.ref.href.target">
<xsl:param name="node" select="."/>
- <xsl:param name="href" select="$node/@href"/>
- <xsl:variable name="conref" select="yelp:dita.ref.conref($node)"/>
+ <xsl:param name="conref" select="yelp:dita.ref.conref($node)"/>
+ <xsl:param name="href">
+ <xsl:call-template name="dita.ref.conref.attr">
+ <xsl:with-param name="attr" select="'href'"/>
+ <xsl:with-param name="node" select="$node"/>
+ <xsl:with-param name="conref" select="$conref"/>
+ </xsl:call-template>
+ </xsl:param>
<xsl:variable name="format">
<xsl:call-template name="dita.ref.conref.attr">
<xsl:with-param name="attr" select="'format'"/>
@@ -205,7 +211,84 @@ when creating output files from DITA topics.
<xsl:template name="dita.ref.href.target.custom">
<xsl:param name="node" select="."/>
- <xsl:param name="href" select="$node/@href"/>
+ <xsl:param name="conref" select="yelp:dita.ref.conref($node)"/>
+ <xsl:param name="href">
+ <xsl:call-template name="dita.ref.conref.attr">
+ <xsl:with-param name="attr" select="'href'"/>
+ <xsl:with-param name="node" select="$node"/>
+ <xsl:with-param name="conref" select="$conref"/>
+ </xsl:call-template>
+ </xsl:param>
+</xsl:template>
+
+<xsl:template name="dita.ref.href.content">
+ <xsl:param name="node" select="."/>
+ <xsl:param name="conref" select="yelp:dita.ref.conref($node)"/>
+ <xsl:param name="href">
+ <xsl:call-template name="dita.ref.conref.attr">
+ <xsl:with-param name="attr" select="'href'"/>
+ <xsl:with-param name="node" select="$node"/>
+ <xsl:with-param name="conref" select="$conref"/>
+ </xsl:call-template>
+ </xsl:param>
+ <xsl:variable name="format">
+ <xsl:call-template name="dita.ref.conref.attr">
+ <xsl:with-param name="attr" select="'format'"/>
+ <xsl:with-param name="node" select="$node"/>
+ <xsl:with-param name="conref" select="$conref"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="scope">
+ <xsl:call-template name="dita.ref.conref.attr">
+ <xsl:with-param name="attr" select="'scope'"/>
+ <xsl:with-param name="node" select="$node"/>
+ <xsl:with-param name="conref" select="$conref"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$conref/node()[not(self::&topic_desc;)]">
+ <xsl:apply-templates mode="dita2html.topic.mode"
+ select="$conref/node()[not(self::&topic_desc;)]"/>
+ </xsl:when>
+ <xsl:when test="$scope = 'external' or ($format != '' and $format != 'dita')">
+ <xsl:value-of select="@href"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="uri">
+ <xsl:choose>
+ <xsl:when test="contains($href, '#')">
+ <xsl:value-of select="substring-before($href, '#')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$href"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:for-each select="document($uri, .)">
+ <xsl:variable name="frag">
+ <xsl:choose>
+ <xsl:when test="contains($href, '#')">
+ <xsl:value-of select="substring-after($href, '#')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="/*/@id"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="tnode" select="key('dita.id.key', $frag)"/>
+ <xsl:choose>
+ <xsl:when test="$tnode/&topic_titlealts;/&topic_navtitle;">
+ <xsl:apply-templates mode="dita.ref.content.mode"
+ select="$tnode/&topic_titlealts;/&topic_navtitle;/node()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="dita.ref.content.mode"
+ select="$tnode/&topic_title_all;/node()"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<xsl:template name="dita.ref.topicref.navtitle">
diff --git a/xslt/dita/common/dita-selectors.mod b/xslt/dita/common/dita-selectors.mod
index 9486ec7..f84f99c 100644
--- a/xslt/dita/common/dita-selectors.mod
+++ b/xslt/dita/common/dita-selectors.mod
@@ -148,7 +148,24 @@ topic/dthd
<!-- ===========================================================================
topic/fig
-->
-<!ENTITY topic_fig "*[name(.) = 'fig' or contains(@class, ' topic/fig ')]">
+<!ENTITY topic_imagemap "*[
+ name(.) = 'imagemap' or contains(@class, ' topic/fig ut-d/imagemap ')]">
+<!ENTITY topic_fig "*[
+ name(.) = 'fig' or (
+ contains(@class, ' topic/fig ')
+ and not(contains(@class, ' topic/fig ut-d/imagemap '))
+ )]">
+
+<!-- ===========================================================================
+topic/figgroup
+-->
+<!ENTITY topic_area "*[
+ name(.) = 'area' or contains(@class, ' topic/figgroup ut-d/area ')]">
+<!ENTITY topic_figgroup "*[
+ name(.) = 'figgroup' or (
+ contains(@class, ' topic/figgroup ')
+ and not(contains(@class, ' topic/figgroup ut-d/area '))
+ )]">
<!-- ===========================================================================
topic/image
@@ -172,6 +189,8 @@ topic/keyword
-->
<!ENTITY topic_cmdname "*[
name(.) = 'cmdname' or contains(@class, ' topic/keyword sw-d/cmdname ')]">
+<!ENTITY topic_shape "*[
+ name(.) = 'shape' or contains(@class, ' topic/keyword ut-d/shape ')]">
<!ENTITY topic_varname "*[
name(.) = 'varname' or contains(@class, ' topic/keyword sw-d/varname ')]">
<!ENTITY topic_wintitle "*[
@@ -280,6 +299,8 @@ topic/ph
name(.) = 'b' or contains(@class, ' topic/ph hi-d/b ')]">
<!ENTITY topic_cmd "*[
name(.) = 'cmd' or contains(@class, ' topic/ph task/cmd ')]">
+<!ENTITY topic_coords "*[
+ name(.) = 'coords' or contains(@class, ' topic/ph ut-d/coords ')]">
<!ENTITY topic_codeph "*[
name(.) = 'codeph' or contains(@class, ' topic/ph pr-d/codeph ')]">
<!ENTITY topic_filepath "*[
diff --git a/xslt/dita/html/dita2html-inline.xsl b/xslt/dita/html/dita2html-inline.xsl
index 7e80cd0..0435661 100644
--- a/xslt/dita/html/dita2html-inline.xsl
+++ b/xslt/dita/html/dita2html-inline.xsl
@@ -188,67 +188,17 @@ FIXME
<!-- = xref = -->
<xsl:template mode="dita2html.topic.mode" match="&topic_xref;">
<xsl:variable name="conref" select="yelp:dita.ref.conref(.)"/>
- <xsl:variable name="format">
- <xsl:call-template name="dita.ref.conref.attr">
- <xsl:with-param name="attr" select="'format'"/>
- <xsl:with-param name="node" select="."/>
- <xsl:with-param name="conref" select="$conref"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="scope">
- <xsl:call-template name="dita.ref.conref.attr">
- <xsl:with-param name="attr" select="'scope'"/>
- <xsl:with-param name="node" select="."/>
- <xsl:with-param name="conref" select="$conref"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="type">
- <xsl:call-template name="dita.ref.conref.attr">
- <xsl:with-param name="attr" select="'type'"/>
- <xsl:with-param name="node" select="."/>
- <xsl:with-param name="conref" select="$conref"/>
- </xsl:call-template>
- </xsl:variable>
<a>
<xsl:attribute name="href">
- <xsl:call-template name="dita.ref.href.target"/>
+ <xsl:call-template name="dita.ref.href.target">
+ <xsl:with-param name="node" select="."/>
+ <xsl:with-param name="conref" select="$conref"/>
+ </xsl:call-template>
</xsl:attribute>
- <xsl:choose>
- <xsl:when test="$conref/node()[not(self::&topic_desc;)]">
- <xsl:apply-templates mode="dita2html.topic.mode"
- select="$conref/node()[not(self::&topic_desc;)]"/>
- </xsl:when>
- <xsl:when test="$scope = 'external' or ($format != '' and $format != 'dita')">
- <xsl:value-of select="@href"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="href" select="@href"/>
- <xsl:variable name="uri">
- <xsl:choose>
- <xsl:when test="contains($href, '#')">
- <xsl:value-of select="substring-before($href, '#')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$href"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:for-each name="target" select="document($uri, .)">
- <xsl:variable name="frag">
- <xsl:choose>
- <xsl:when test="contains($href, '#')">
- <xsl:value-of select="substring-after($href, '#')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="/*/@id"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="tnode" select="key('dita.id.key', $frag)"/>
- <xsl:apply-templates mode="dita2html.topic.mode" select="$tnode/&topic_title_all;/node()"/>
- </xsl:for-each>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:call-template name="dita.ref.href.content">
+ <xsl:with-param name="node" select="."/>
+ <xsl:with-param name="conref" select="$conref"/>
+ </xsl:call-template>
</a>
</xsl:template>
diff --git a/xslt/dita/html/dita2html-media.xsl b/xslt/dita/html/dita2html-media.xsl
index 3c21543..3ae2726 100644
--- a/xslt/dita/html/dita2html-media.xsl
+++ b/xslt/dita/html/dita2html-media.xsl
@@ -35,6 +35,7 @@ REMARK: Describe this module
<!-- = image = -->
<xsl:template mode="dita2html.topic.mode" match="&topic_image;">
+ <xsl:param name="usemap" select="''"/>
<xsl:variable name="conref" select="yelp:dita.ref.conref(.)"/>
<xsl:variable name="placement">
<xsl:call-template name="dita.ref.conref.attr">
@@ -49,6 +50,7 @@ REMARK: Describe this module
<div class="inner">
<xsl:call-template name="_dita2html.image.img">
<xsl:with-param name="conref" select="$conref"/>
+ <xsl:with-param name="usemap" select="$usemap"/>
</xsl:call-template>
</div>
</div>
@@ -57,6 +59,7 @@ REMARK: Describe this module
<span class="media media-image">
<xsl:call-template name="_dita2html.image.img">
<xsl:with-param name="conref" select="$conref"/>
+ <xsl:with-param name="usemap" select="$usemap"/>
</xsl:call-template>
</span>
</xsl:otherwise>
@@ -67,6 +70,7 @@ REMARK: Describe this module
<xsl:template name="_dita2html.image.img">
<xsl:param name="node" select="."/>
<xsl:param name="conref" select="yelp:dita.ref.conref($node)"/>
+ <xsl:param name="usemap" select="''"/>
<xsl:variable name="href">
<xsl:call-template name="dita.ref.conref.attr">
<xsl:with-param name="attr" select="'href'"/>
@@ -103,6 +107,11 @@ REMARK: Describe this module
</xsl:attribute>
</xsl:if>
</xsl:if>
+ <xsl:if test="$usemap != ''">
+ <xsl:attribute name="usemap">
+ <xsl:value-of select="$usemap"/>
+ </xsl:attribute>
+ </xsl:if>
<xsl:choose>
<xsl:when test="&topic_alt;">
<xsl:attribute name="alt">
@@ -123,6 +132,48 @@ REMARK: Describe this module
</img>
</xsl:template>
+<!-- = imagemap = -->
+<xsl:template mode="dita2html.topic.mode" match="&topic_imagemap;">
+ <xsl:variable name="conref" select="yelp:dita.ref.conref(.)"/>
+ <xsl:variable name="name">
+ <xsl:choose>
+ <xsl:when test="@id">
+ <xsl:value-of select="@id"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="generate-id()"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:apply-templates mode="dita2html.topic.mode" select="$conref/&topic_image;">
+ <xsl:with-param name="usemap" select="concat('#', $name)"/>
+ </xsl:apply-templates>
+ <map name="{$name}">
+ <xsl:apply-templates mode="dita2html.topic.mode" select="$conref/&topic_area;"/>
+ </map>
+</xsl:template>
+
+<!-- = area = -->
+<xsl:template mode="dita2html.topic.mode" match="&topic_area;">
+ <xsl:variable name="conref" select="yelp:dita.ref.conref(.)"/>
+ <area>
+ <xsl:attribute name="shape">
+ <xsl:value-of select="$conref/&topic_shape;"/>
+ </xsl:attribute>
+ <xsl:attribute name="coords">
+ <xsl:value-of select="$conref/&topic_coords;"/>
+ </xsl:attribute>
+ <xsl:for-each select="&topic_xref;[1]">
+ <xsl:attribute name="href">
+ <xsl:call-template name="dita.ref.href.target"/>
+ </xsl:attribute>
+ <xsl:attribute name="title">
+ <xsl:call-template name="dita.ref.href.content"/>
+ </xsl:attribute>
+ </xsl:for-each>
+ </area>
+</xsl:template>
+
<!-- = object = -->
<xsl:template mode="dita2html.topic.mode" match="&topic_object;">
<xsl:variable name="node" select="."/>
@@ -146,7 +197,7 @@ REMARK: Describe this module
</xsl:call-template>
</xsl:attribute>
</xsl:for-each>
- <xsl:apply-templates mode="dita2html.topic.mode" select="&topic_param;"/>
+ <xsl:apply-templates mode="dita2html.topic.mode" select="$conref/&topic_param;"/>
</xsl:element>
</div>
</div>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]