1<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 2 <xsl:param name="basedir"/> 3 <xsl:output method="xml" encoding="utf-8" indent="yes"/> 4 <!-- --> 5 <!-- Template for the root so we can add a DOCTYPE --> 6 <xsl:template match="/"> 7 <xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ 8<!ENTITY % BOOK_ENTITIES SYSTEM "Wayland.ent"> 9%BOOK_ENTITIES; 10]> 11]]></xsl:text> 12 <xsl:apply-templates select="@*|node()"/> 13 </xsl:template> 14 <!-- --> 15 <xsl:template match="@*|node()"> 16 <xsl:copy> 17 <xsl:apply-templates select="@*|node()"/> 18 </xsl:copy> 19 </xsl:template> 20 <!-- --> 21 <!-- suppress existing image map areas --> 22 <xsl:template match="area"/> 23 <!-- --> 24 <xsl:template match="areaspec[area][name(..)='imageobjectco']"> 25 <xsl:element name="areaspec"> 26 <xsl:apply-templates select="@*"/> 27 <xsl:text>
</xsl:text> 28 <xsl:variable name="pngfile" select="../imageobject/imagedata/@fileref"/> 29 <xsl:variable name="mapfile" select="concat(substring($pngfile, 1, string-length($pngfile)-3), 'map')"/> 30 <xsl:variable name="maproot" select="document(concat($basedir, '/', $mapfile))"/> 31 <!-- --> 32 <!-- now emit the needed areas --> 33 <xsl:for-each select="area"> 34 <xsl:variable name="anchor" select="."/> 35 <xsl:variable name="other" select="($maproot)//area[@href=($anchor)/@x_steal]"/> 36 <xsl:choose> 37 <xsl:when test="$other"> 38 <xsl:text>	 </xsl:text> 39 <xsl:element name="area"> 40 <xsl:attribute name="id"> 41 <xsl:value-of select="@id"/> 42 </xsl:attribute> 43 <xsl:attribute name="linkends"> 44 <xsl:value-of select="@linkends"/> 45 </xsl:attribute> 46 <xsl:attribute name="coords"> 47 <xsl:value-of select="($other)/@coords"/> 48 </xsl:attribute> 49 </xsl:element> 50 </xsl:when> 51 <xsl:otherwise> 52 <xsl:text>	 </xsl:text> 53 <xsl:comment> 54 <xsl:value-of select="concat('Warning: unable to locate area tagged ', ($anchor)/@x_steal)"/> 55 </xsl:comment> 56 </xsl:otherwise> 57 </xsl:choose> 58 <xsl:text>
</xsl:text> 59 </xsl:for-each> 60 <!-- --> 61 <xsl:text>	 </xsl:text> 62 </xsl:element> 63 </xsl:template> 64</xsl:stylesheet> 65