- From: Max Froumentin <mf@w3.org>
- Date: Mon, 17 Jun 2002 11:52:58 +0200
- To: batik-users@xml.apache.org, www-svg@w3.org
- Cc: Vincent Hardy <vincent.hardy@sun.com>
Darya Said-Akbari wrote: > I have a XML file, a XSL file and a SVG file. In the > SVG file I put a number of SVG text elements as same > as in the XML file are included. > > How can I make the SVG text elements available to XSL? > So, that during XSL Transformation the values from my > XML file are included into the SVG. Hi Darya, If I understand you correctly, you have a template SVG file as well as an XML file that contains some text, and you want to produce a new SVG file by inserting the text from the XML file into the SVG template. In that case, I suppose your XSL file should be identity transform of your SVG, except in places where you want to insert the text, where you should have templates that get the text from the XML file and insert it. For instance, something like: <!-- identity transform --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!-- template that picks up anchors in the SVG and get the corresponding text fromt the xml file --> <xsl:template match="text[.='anchorA']> <text><xsl:value-of select="document('text.xml')/texts/txt[@id='anchorA']"/></text> </xsl:template> with an XML file that looks like: <texts> <txt id="A">Hello World!</txt> </texts> will replace, in the SVG: <text>anchorA</text> with <text>Hellow World!</text> In fact, you can generalise the anchor template so you only need one for all your txt elements: <xsl:template match="text[starts-with(.,'anchor')]"> <text> <xsl:value-of select="document('text.xml')/texts/txt[@id = substring(.,7,1)]"/> </text> </xsl:template> Hope this helps, Max.
Received on Monday, 17 June 2002 05:53:05 UTC