Re: [xsl] SVG Help

Subject: Re: [xsl] SVG Help
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 1 Nov 2004 13:55:34 +0000
Hi Kent,

> 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"?>

That should be:

  <?xml-stylesheet type="text/xsl" href="circle.svg.xsl"?>
       ^
  hyphen, not colon

> 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";>

If you're generating SVG, and don't want to use the 'svg' prefix
throughout your stylesheet, you should make the SVG namespace the
default namespace for the stylesheet. In other words, change:

  xmlns:svg="http://www.w3.org/2000/svg";

to:

  xmlns="http://www.w3.org/2000/svg";

> 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"

The namespace issue is one problem: SVG processors will (should) only
recognize SVG that is in the SVG namespace.

The other problem is that I suspect you're expecting to simply load
the XML into Internet Explorer and have the SVG be shown
automatically. That won't happen: IE expects the result of any
transformation that it does to be an HTML document, and it will
display the result of any transformation as if it were an HTML
document. The result that you're getting is consistent with IE
ignoring non-HTML elements and just showing their contents.

If you want to do client-side transformation in IE, you need the
stylesheet to generate an HTML page containing an SVG object, and then
load the SVG image into that object. See Chris Bayes's DOM to DOM
utility at:

  http://www.bayes.co.uk/xml/portal.asp?page=/xml/index.xml&subpage=/xml/utils/domtodom.xml

for details.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Current Thread