XPath/XSLT support in Safari

Written by on February 23rd, 2007 in Ajax News.

Ruben Daniels was on a mission to create XPath and XSLT support that works on Safari.

This isn’t the first effort:

After searching the web I found several XPath/XSLT implementations:

I always try to keep the socalled ‘footprint’ of the application as low as possible. Loading a more than 100KB library to just add some functionality that should’ve existed in the first place, was unacceptable. The JS-XPath library only extends the one already available in IE. So I started building an XPath implementation myself with only one goal in mind; Create the smallest Xpath and XSLT implementation in javascript possible.

He ended up with some small libraries, and he discusses how he got there in his entry.

How to use it

JAVASCRIPT:

  1.  
  2. // xpath
  3. var nodeset = XPath.selectNodes(”//j:teleport/node()|text()”, xmlContextNode);
  4.  
  5. // xslt
  6. var xsltProcessor = new XSLTProcessor();
  7. xsltProcessor.importStylesheet(xslDoc);
  8. d = document.implementation.createDocument(”", “”, null);
  9. f = xsltProcessor.transformToFragment(this, d);
  10.  

Source: Ajaxian
Original Article: http://ajaxian.com/archives/xpathxslt-support-in-safari

Leave a Reply

You must be logged in to post a comment.



Site Navigation