RE: Displaying SVG

Subject: RE: Displaying SVG
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Fri, 25 Aug 2000 18:49:09 +0100
>  svg= open("demo.svg", "displayWindow",
This line will work on it's own

>  svg.document.writeln(strResult)
>  svg.document.close();

This won't work because open only accepts text/html
quoting msdn

open Method


Opens a document to collect the output of write or writeln methods.


oNewDoc = [, sReplace])

sMimeType Required. String that specifies the MIME type. Currently supports
"text/html" only.
sReplace Optional. String that specifies whether the new document being
written is to replace the current document in the History list. Otherwise,
by default, the document being created does not replace the current document
in the History list.

Return Value

Returns a reference to the new document.

I looked at the svg dom and there is no loadXML method which is a pity. But
it does have createElement and insert etc so it would be possible to use the
output of a transform to create a representation using the adobe plugin. Off
the top of my head something like

var xml = new ActiveXObject("Microsoft.XMLDOM");
var xsl = new ActiveXObject("Microsoft.XMLDOM");
var svg = new ActiveXObject("Microsoft.XMLDOM");
var svgdoc = document.embeds[svg_name].getSVGDocument();
xml.transformNodeToObject(xsl, svg);
//clear the svgdoc first
copyNode(svg.documentElement, svgdoc.documentElement, svg, svgdoc);

function copyNode(snode, dnode, svg, svgdoc){
	var i=0;
	for(i=0; i < svg.childNodes.length; i++){
		case NODE_ELEMENT: //1
			var newNode = svgdoc.createElement(svg.childNodes[i].nodeName);
			copyAttributes(svg.childNodes[i], newNode);
			copyNode(svg.childNodes[i], newNode, svg, svgdoc);
		case etc...
function copyAttributes(sNode, dNode){etc}

I have seen some code over the last week that does something similar for a
different problem but I've lost it. If you do work this out I can think of a
lot of places where it could be used so send me a copy. Maybe I'll have a
play with it this weekend too.

Ciao Chris

XML/XSL Portal

>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Gert Bultman
>Sent: 25 August 2000 16:29
>To: xsl-list@xxxxxxxxxxxxxxxx
>Subject: Displaying SVG
>I've slightly altered Michael Kay's examples from Appendix A in his
>(excellent) XSLT book to run a stylesheet which produces SVG. I have
>IE5.5 with the necessary plugin, and when I load an SVG file it displays
>properly. However, when I want to display the generated svg in a new
>window, the window stays blank, even though I specify the mime-type
>(code from the Voodoo manual):
>  svg= open("demo.svg", "displayWindow",
>  svg.document.writeln(strResult)
>  svg.document.close();
>I chose to open a new window, because displaying the svg in the
>DIV.innerhtml won't work at all. The plugin doesn't recognize it.
>The best solution would be proper inline svg, but I don't think any
>browser supports it.
>If I specify the mime-type text/plain, the svg code display as text, as
>Any suggestions?
>Gert Bultman
>Delft Technical University
>Computer Graphics Dept.
>The Netherlands
> XSL-List info and archive:

 XSL-List info and archive:

Current Thread