W3C home > Mailing lists > Public > www-svg@w3.org > June 2002

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

From: Max Froumentin <mf@w3.org>
Date: Tue, 18 Jun 2002 13:44:54 +0200
To: Darya Said-Akbari <darya_akbari@yahoo.com>
Cc: batik-users@xml.apache.org, www-svg@w3.org, Vincent Hardy <vincent.hardy@sun.com>
Message-ID: <86n0ts95ft.fsf@sophia.inria.fr>

Darya Said-Akbari <darya_akbari@yahoo.com> writes:

> <?xml version="1.0"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
> "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
> <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

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:46:53 UTC