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