views:

39

answers:

1

I am making a REST call that returns XML from within a Widget in Zendesk using an <iframe/>.

I would like to use XSLT to transform the XML into HTML that is rendered within the <iframe/>

Is there any way I can write my XSLT inline, and have the <iframe/> somehow execute the xslt transformation, yielding the HTML to show in the <iframe/>?

+1  A: 

You should be able to perform a complete XSLT in JavaScript, using something such as the following:

var xsl = (new DOMParser()).parseFromString('<your-xsl-sheet-here', 'text/xml');
var xslt = new XSLTProcessor();
xslt.importStylesheet(xsl);
var transformedData = xslt.transformToFragment(yourXMLDataHere,document);

I would absolutely recommend doing the XSLT server-side whenever possible, but it can be done client side as well.

BuckWild