Engywook
06-23-2008, 05:43 PM
I'm using XSL to transform an XML file; however, there is some additional string handling I would want to do between the time the transformation is done and display on page.
Code for non-IE browsers, adopted from w3schools, is here:
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
/*transFormToFragment returns an object, not a string
The object returned has no methods or properties.
How can anything be done with this text aside from appending it? */
resultDocument = xsltProcessor.transformToFragment(xml,document);
/*This is my workaround - append the object to a hidden div....*/
whereHide=where+"Hidden";
document.getElementById(whereHide).appendChild(resultDocument);
/*Then use javascript on the contents of the hidden div...*/
textCrunch=document.getElementById(whereHide).innerHTML;
textCrunch=scrubTags(textCrunch);
/*....finally, send it to where I really want it to go*/
document.getElementById(where).innerHTML=textCrunch;
None too elegant, I'll be first to admit. Is there a way to get the text out of the object created by the transformToFragment method? Or is there another way to do a transformation that will work without ActiveX?
Code for non-IE browsers, adopted from w3schools, is here:
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
/*transFormToFragment returns an object, not a string
The object returned has no methods or properties.
How can anything be done with this text aside from appending it? */
resultDocument = xsltProcessor.transformToFragment(xml,document);
/*This is my workaround - append the object to a hidden div....*/
whereHide=where+"Hidden";
document.getElementById(whereHide).appendChild(resultDocument);
/*Then use javascript on the contents of the hidden div...*/
textCrunch=document.getElementById(whereHide).innerHTML;
textCrunch=scrubTags(textCrunch);
/*....finally, send it to where I really want it to go*/
document.getElementById(where).innerHTML=textCrunch;
None too elegant, I'll be first to admit. Is there a way to get the text out of the object created by the transformToFragment method? Or is there another way to do a transformation that will work without ActiveX?