Re: XML to SVG... more info (A working version)

Hi again Rick & Libo,

I have taken Libo's code which he posted earlier and made some 
corrections/changes. It now works for me - it produces the text "Paco" in red 
at the top left of the browser window with a black rectangle below and to the 
right.

I will post the XML file, XSLT transformation sheet and the output SVG file 
(from Instant Saxon). I guess you will be able to spot the changes and see if 
this code, which works for me, also works for you.

The XML file is:

<?xml version="1.0" ?>
    <?xml-stylesheet href="convertsvg1.xsl" type="text/xsl"?>
<Result>
    <Name>"Paco"</Name>
</Result>

The XSLT file is:

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

  
<xsl:output indent="yes" media-type="svg-xml" />
  <xsl:strip-space elements="*"/>

<!-- Add DOCTYPE -->
<xsl:template match="/">
<!--
    <xsl:text disable-output-escaping="yes">&lt;!DOCTYPE svg PUBLIC
"-//W3C//DTD SVG 20000802//EN" 
      "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd"&gt;
    </xsl:text>
-->    
    <xsl:apply-templates/>
</xsl:template>

<xsl:template match="Name">
    <svg width="500" height="500">
        <text x="0.5cm" y="0.5cm" style="font-family:Verdana;
font-size:16pt; fill:red">       
            <xsl:value-of select='.'/>   
        </text>
        <rect x="2cm" y="1cm" width="6cm" height="3cm"/>
    </svg>
</xsl:template>

</xsl:stylesheet>

The SVG file which Instant Saxon output was:

<?xml version="1.0" encoding="utf-8" ?><svg width="500" height="500"><text 
x="0.5cm" y="0.5cm" style="font-family:Verdana; font-size:16pt; fill:red">"Pac
o"</text><rect x="2cm" y="1cm" width="6cm" height="3cm"/></svg>

That SVG file displayed in IE5.5 as described above.

I hope that helps you both to get it working on your own systems.

Andrew Watt

Received on Thursday, 24 August 2000 13:40:49 UTC