xsl-list
[Top] [All Lists]

[xsl] Optimizing identity template

2009-01-21 18:52:55
Hello xsl-list,

 I am wondering whether the following (working) stylesheet could be
 improved. It is supposed to output an SVG map with a
 circle pointing to specific coordinates:

 1. load an external SVG file ($basemap).
 2. copy entire SVG file, adding <circle> as the last element

 This is for PHP5/libxslt, but there will also be an XSLT 2/Saxon version.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:svg="http://www.w3.org/2000/svg";>

        <xsl:output method="xml" omit-xml-declaration="no" indent="yes" 
encoding="UTF-8"/>
   
        <xsl:template match="/">
                <xsl:apply-templates select="document($basemap)/svg:svg"/>
        </xsl:template>
        
        <xsl:template match="/svg:svg/*[position()=last()]">
                <xsl:copy>
                        <xsl:apply-templates select="@*|node()"/>
                </xsl:copy>
                <circle xmlns="http://www.w3.org/2000/svg";
                cx="100px" cy="100px" r="5px"
                fill="#ff0000" stroke="#000000" stroke-width="1px"/>
        </xsl:template>
        
        <xsl:template match="node()|@*">
                <xsl:copy>
                        <xsl:apply-templates select="@*|node()"/>
                </xsl:copy>
        </xsl:template>

</xsl:stylesheet>

--
Best regards,
Jacek Iwański
jiva(_at_)ceti(_dot_)pl


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>