RE: Displaying SVG

Subject: RE: Displaying SVG
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Fri, 25 Aug 2000 18:49:09 +0100
Gert,
>  svg= open("demo.svg", "displayWindow",
>"width=500,height=400,status=yes,toolbar=yes,menubar=yes");
This line will work on it's own

>  svg.document.open("image/svg-xml");
>  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.

Syntax

oNewDoc = document.open(sMimeType [, sReplace])
Parameters

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++){
		switch(svg.childNodes[i].nodeType){
		case NODE_ELEMENT: //1
			var newNode = svgdoc.createElement(svg.childNodes[i].nodeName);
			copyAttributes(svg.childNodes[i], newNode);
			dnode.appendChild(newNode);
			copyNode(svg.childNodes[i], newNode, svg, svgdoc);
			break;
		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
http://www.bayes.co.uk/xml


>-----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",
>"width=500,height=400,status=yes,toolbar=yes,menubar=yes");
>  svg.document.open("image/svg-xml");
>  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
>expected.
>Any suggestions?
>
>Gert Bultman
>Delft Technical University
>Computer Graphics Dept.
>The Netherlands
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread