This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Mozilla XML > September 2005 > How to get XSLTProcessor.transformToDocument output in a tab/document?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How to get XSLTProcessor.transformToDocument output in a tab/document?
Michael Vincent van Rantwijk

2005-09-07, 7:49 am

Hi,

How do I display a XSL Transformed XMLDocument(fragment) after
reading it in with XMLHttpRequest.open("GET", aURL) ???

Something like this works when I first load the XML uri into a tab:

var ownerDocument = document.implementation.createDocument("", "", null);
var newFragment = processor.transformToFragment(doc, ownerDocument);
var _documentElement = doc.documentElement;

while (_documentElement.hasChildNodes())
_documentElement.removeChild(_documentElement.firstChild);
_documentElement.appendChild(newFragment);

But I don't want to load it into a tab.
I just want to load it, transform it and put the output into a tab.
I use this:

var newDocument = processor.transformToDocument(XMLHttpRequest.responseXML);

instead of method transformToFragment (I hope that's the right thing use)
without any warnings and errors, so it seems to be fine but...there's no
output. Or when I change it a little, the complete window is overwritten
replaced with the backgkround of my XSL stylesheet and a text for empty
sidebar is displayed, so I must be doing something very wrong.

Again, everything works when I call my function *after* entering the URL
into
the locationbar, but that's not what I want!

Uhg, I hope I made myself clear.
I whish my English was a little better--maybe next year ;)

TIA
Michael
Michael Vincent van Rantwijk

2005-09-07, 8:03 pm

Michael Vincent van Rantwijk wrote:
> Hi,
>
> How do I display a XSL Transformed XMLDocument(fragment) after
> reading it in with XMLHttpRequest.open("GET", aURL) ???
>
> Something like this works when I first load the XML uri into a tab:
>
> var ownerDocument = document.implementation.createDocument("", "", null);
> var newFragment = processor.transformToFragment(doc, ownerDocument);
> var _documentElement = doc.documentElement;
>
> while (_documentElement.hasChildNodes())
> _documentElement.removeChild(_documentElement.firstChild);
> _documentElement.appendChild(newFragment);
>
> But I don't want to load it into a tab.
> I just want to load it, transform it and put the output into a tab.
> I use this:
>
> var newDocument =
> processor.transformToDocument(XMLHttpRequest.responseXML);
>
> instead of method transformToFragment (I hope that's the right thing use)
> without any warnings and errors, so it seems to be fine but...there's no
> output. Or when I change it a little, the complete window is overwritten
> replaced with the backgkround of my XSL stylesheet and a text for empty
> sidebar is displayed, so I must be doing something very wrong.
>
> Again, everything works when I call my function *after* entering the URL
> into
> the locationbar, but that's not what I want!
>
> Uhg, I hope I made myself clear.
> I whish my English was a little better--maybe next year ;)
>
> TIA
> Michael


I now get a transformed XML document in getBrowser().contentDocument

Ok, the images don't look right yet (will have to find out why) and I
have duplicated entries at the top of the document for HTML/HEAD/TITLE
and BODY (which I assume should be remove before I add the new fragment)
but at least I made some progress ;)

Michael
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews