Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

Transforming XML to HTMl and SVG Client Side

Hi again.

I have an XML file I wish to transfom client side with XSLT.

The XML file contain a series of geometric points and their various attributes.

What I wish to create is an HTML page that contains a table with the attributes as well as an SVG map showing the points (using a WMS service map as a background).

Now, transforming XML to HTML is 'simple' and I see no trouble in transforming my XML to SVG either. However, I do not wish to start saving files on the client side PC, so how do I show my SVG in the HTML I generated.

I have previously been using the <embed> tag, but as far as I know, this requires me to have an actual file to be used in the src attribute to show my SVG.

Any help would be appreciated.
  • 2
  • 2
1 Solution
hm...you need yo embed CVG into HTML right?
i think you can achive this using DOM manipulation with JS.

so, somthing like transform XML to SVG, and put it in 'right' part of DOM tree.

What component are you using to render SVG?

What Browser(s) are you targeting?

It is likely that the SVG component will accept a URL for a file to render is it unacceptable to round trip to the server and have the Server perform the XML to SVG transform?

FinduilasAuthor Commented:
My situation is this:

On a IE browser with Adobes SVGViewer (connected via a GPRS Modem) I have an XML file displayed in a certain way (through standard XSLT).

Now I wish to change the display, so I run a JavaScript function to display the XML as an HTML page with a standard table (showing attributes from the XML) and a map in SVG.

Both the HTML and the SVG can be made through using two different XSL's on my XML (and as I have a limited number of defined user's, I can load the XSL's from the local machine - so I don't require to establish a connection to the server even once).

So I can display the HTML code containing an <embed> tag to hold the SVG, but I cannot get <embed> to work without a src attribute specifying a file. However, I have my SVG code in memory - So how do I display it? Saving the SVG file locally on the machine is not neccessarily a good idea, as it would conflict with the standard security of my internet browser.
Version 3.0 of Adobe's SVGViewer has a getSVGDocument method.  Which is exposes the underlying XML DOM for the SVG.  You may be able to manipulate the content of the SVG using that in JavaScript I guess like this:-

function displaySVG(oMySVGDOM)
  oSVGDOM = SVGCtl.getSVGDocument
  if (oSVGDOM.nodeType != 9) oSVGDOM = oSVGDOM.ownerDocument

  oSVGDOM.replaceChild(oMySVGDOM.documentElement, oSVGDOM.documentElement)

Again guessing you might need to give the SVG src a URL to a small 'empty' SVG to ensure the there is a Document to get.  However I suspect that the SVG control will create an empty one of it's own if SRC isn't supplied.

FinduilasAuthor Commented:
I guess it must be something like this.

However, when I parse an XML document through an MSXML processor and recieve an SVG output string, I can find no method of reading this string into an SVG document....

I will ask this question in a seperate question - I assume I have overlooked something rather simple.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now