xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Max Froumentin ...@w3.org>
Subject Re: [Fwd: Merging SVG and XML with XSL Transformation?]
Date Tue, 18 Jun 2002 11:44:54 GMT
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"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:svg="http://www.w3.org/2000/svg">

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="@*"/>
 <svg:text><xsl:value-of
select="document('text.xml')/texts/txt[@id='anchorA']"/></text>
</xsl:template>

Max.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message