This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: [docbook-apps] imagedata as olink anchors
- From: "administrator at ivanmoravec dot net" <denis dot bradford at verizon dot net>
- To: docbook-apps at lists dot oasis-open dot org
- Date: Mon, 26 Apr 2004 18:32:13 -0400
- Subject: Re: [docbook-apps] imagedata as olink anchors
> Regarding image maps, there is no support in the DocBook
> stylesheets for them. Perhaps someone has written a
> customization that can do that.
I implemented a client-side image map. An example is in my Website
project at http://www.ivanmoravec.net/schedule/schedule.html. On the
image side I customized two templates in docbook/html/graphics.xsl. The
map side then just required a few simple new templates. Source markup is
pretty straightforward.
FWIW, here's how it works:
Sample page source markup:
--------------------------
<mediaobject>
<imageobject> <!-- image to be mapped -->
<?usemap mymap?> <!-- PI to specify the map name -->
<imagedata depth="134px" fileref="../images/bigworld.gif"
width="512px"/>
</imageobject>
.
.
.
<!-- Section for map. label must match name in usemap PI. -->
<section label="mymap" role="imagemap">
<title role="ignore"></title>
<para role="area">
<phrase role="shape">CIRCLE</phrase>
<phrase role="coords">401,53,4</phrase>
<phrase role="href">#apr29.2004gig</phrase>
<phrase role="alt">Prague 29.4.2004</phrase>
</para>
<para role="area">
<phrase role="shape">CIRCLE</phrase>
.
.
.
</section>
XSL customizations (with a little context):
-------------------------------------------
1. <xsl:template name="process.image">
<xsl:param name="mapname"/> <!-- imagemap customization -->
.
.
.
<xsl:if test="@align">
<xsl:attribute name="align">
<xsl:choose>
<xsl:when test="@align = 'center'">middle</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@align"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:if>
<!-- imagemap customization -->
<xsl:if test="$mapname">
<xsl:attribute name="usemap">
<xsl:text>#</xsl:text><xsl:value-of select="$mapname"/>
</xsl:attribute>
</xsl:if>
<!-- end imagemap customization -->
2. <xsl:template match="imagedata">
.
.
.
<xsl:call-template name="process.image">
<!-- imagemap customization -->
<xsl:with-param name="mapname">
<xsl:value-of
select="ancestor::*/processing-instruction('usemap')"/>
</xsl:with-param>
<!-- end imagemap customization -->
3. New templates:
<xsl:template match="section[@role='imagemap']">
<map>
<xsl:attribute name="name">
<xsl:value-of select="./@label"/>
</xsl:attribute>
<xsl:apply-templates/>
</map>
</xsl:template>
<xsl:template match="para[@role='area']">
<xsl:text>
</xsl:text>
<area>
<xsl:attribute name="shape">
<xsl:value-of select="phrase[@role='shape']"/>
</xsl:attribute>
<xsl:attribute name="coords">
<xsl:value-of select="phrase[@role='coords']"/>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="phrase[@role='href']"/>
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="phrase[@role='alt']"/>
</xsl:attribute>
</area>
</xsl:template>
To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/.