background preloader

Air

Facebook Twitter

Comments

Hack Your Work Day: 100 Awesome Adobe AIR Apps for Productivity. Brian Riggs: Using AIR for XSLT Processing. Air xslt One of the features we’re investigating for the next version of the media player requires that we be able to do client-side XSL transformations.

Brian Riggs: Using AIR for XSLT Processing

I had heard a few rumors that AIR exposes the XSLT processor that’s built into WebKit (which is AIR’s embedded HTML engine), so I shot off a couple of emails to the AIR team. Sure enough, this functionality is exposed through AIR’s Javascript API. Here’s a Javascript method that takes an XML document, an XSL transformation, and returns the result of transforming the document: function transformXML(xml,xsl) { var domParser = new DOMParser(); var xmlObject = domParser.parseFromString(xml,"text/xml"); var xslObject = domParser.parseFromString(xsl,"text/xml"); var xsltProcessor = new XSLTProcessor(); xsltProcessor.importStylesheet(xslObject); var result = xsltProcessor.transformToFragment( xmlObject,document); var serializer = new XMLSerializer(); return serializer.serializeToString(result); }