Re: [Fwd: Merging SVG and XML with XSL Transformation?]

Darya Said-Akbari <> writes:

> <?xml version="1.0"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
> "">
> <svg width="500" height="500">
> 	<text x="51px" y="40px"
> style="fill:rgb(255,0,0);font-size:12;font-family:Arial">anchorA</text>
> </svg>

Ah, tricky that one.  The DOCTYPE above adds an implicit namespace
declaration to the SVG markup.  So, the stylesheet fails to match
"text[.='anchorA']" because it is looking for a <text> element in no
namespace, while the <text> element in infile.svg is in the SVG
namespace. So what you can do is to change your stylesheet by adding
a namespace declaration for SVG:

<xsl:stylesheet version="1.0"

and add the prefix to your xpath expression:

<xsl:template match="svg:text[.='anchorA']">

(and the generated element: <svg:text><xsl:value=of .../></svg:text>)

In fact, perhaps you also want the attributes of <text> copied over. In
that case use:

<xsl:template match="svg:text[.='anchorA']">
 <xsl:copy-of select="@*"/>


Received on Tuesday, 18 June 2002 07:45:28 UTC