Re: [xsl] SVG Help

Subject: Re: [xsl] SVG Help
From: Raffaele Sena <raff@xxxxxxxxxxxx>
Date: Sun, 31 Oct 2004 15:19:07 -0800
Kent,

I just run your code through my favorite XSLT processor (xt) and I think I got the correct result:

<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 800 400" xmlns:svg="http://www.w3.org/2000/svg"; xmlns:xlink="http://www.w3.org.1999/xlink";>
<circle r="100" cx="50%" cy="50%" fill="orange" stroke="black" stroke-width="10"/>
<g text-anchor="middle" font-size="20" fill="red">
<desc>Timeline Markers</desc>
<text x="400" y="100">This is text</text>August</g>
</svg>


The text that you show seems to be exactly the plain text in the output XML file (the content of <g> <desc> and <text>).

You don't explain how do you run your transformation but I suspect that you do it through an XSLT-enabled web browser and you are expecting to see the output displayed by the Adobe SVG plugin (but instead you see the text as if the content was an HTML page with a lot of unknown tags).

One explanation could be that the "media-type" that you add to the <xsl:output> instruction doesn't correctly get converted to Content-Type in the HTTP response (and so the browser doesn't know that it should launch the SVG plugin).

Another explanation is that you define the namespaces for svg and xlink but then you never use them. Shouldn't you prepend the SVG tags with the "svg" namespace ? (i.e. <svg:svg>) or at least declare svg your default output namespace.

Hope this helps,

Raffaele


On Sunday, October 31, 2004, at 02:03 PM, Kent Seegmiller wrote:


I am trying to creat a very simple svg doc using the following source
document: (August.xml)

<?xml version='1.0'?>
<?xml:stylesheet type="text/xsl" href="circle.svg.xsl"?>
<claims>
<header>August</header>
<cpu>No</cpu>
<comm>All Vendors</comm>
<claim claimable="no">
   <vendorcode>B1341</vendorcode>
   <vendorname>PILGRIMS PRIDE</vendorname>
   <vendorRollontime> 99 </vendorRollontime>
   <vendorontime> 100 </vendorontime>
   <cons> 104 </cons>
   <carrier>DETCO</carrier>
   <carrierontime> 90 </carrierontime>
   <loadnum>226347</loadnum>
   <po>1914824</po>
   <due>8/1/2004 </due>
   <original>8/1/2004 11:10:00 PM </original>
   <scheduled>8/1/2004 11:10:00 PM </scheduled>
   <actual>8/1/2004 9:28:00 PM </actual>
   <vendstat>On Time</vendstat>
   <carrierstat>On Time</carrierstat>
   <buyer>NOEL BAKER</buyer>
</claim>
...
</claims>

using the following stylesheet: (circle.svg.xsl)

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

<xsl:strip-space elements="*"/>

<xsl:output method="xml" media-type="image/svg+xml"
   indent="yes" encoding="ISO-8859-1"/>

<xsl:template match="claims">
  <svg viewBox="0 0 800 400">
    <circle r="100" cx="50%" cy="50%"
    fill="orange" stroke="black" stroke-width="10"/>
    <xsl:call-template name="markers"/>
  </svg>
</xsl:template>

<xsl:template name="markers">
  <g text-anchor="middle" font-size="20" fill="red">
  <desc>Timeline Markers</desc>
  <text x="400" y="100">This is text</text>
  <xsl:apply-templates select="header"/>
  </g>
</xsl:template>

<xsl:template match="header">
  <xsl:value-of select="."/>
</xsl:template>

</xsl:stylesheet>

I have followed the format in Jeni Tennisons book "Beginning XSLT" But all I
get is plain unformated text such as:


"Timeline Markers This is textAugust"

Can anyone solve this mystery for this befuddled newbie?

-Thanks, Kent Seegmiller



!DSPAM:41855881310472038551239!

Current Thread