rraguso / ajaxslt

Automatically exported from code.google.com/p/ajaxslt
Other
0 stars 0 forks source link

-- mode: text --

AJAXSLT -- AN XSLT PROCESSOR LIBRARY FOR AJAX APPLICATIONS

INTRODUCTION

AJAXSLT is an implementation of XSLT in JavaScript. Because XSLT uses XPath, it is also an implementation of XPath that can be used independently of XSLT. This implementation has the advantange that it makes XSLT uniformly available on more browsers than natively provide it, and that it can be extended to still more browsers if necessary.

AJAXSLT is interesting for developers who strive aggressively for cross browser compatibility of their advanced web applications.

This implementation of XSLT operates at the DOM level on its input documents. It internally uses a DOM implementation to create the output document, but usually returns the output document as text stream. The DOM to construct the output document can be supplied by the application, or else an internal minimal DOM implementation is used. This DOM comes with a minimal XML parser that can be used to generate a suitable DOM representation of the input documents if they are present as text.

TESTS AND USAGE EXAMPLES

The files ending in _unittest.html are jsunit test pages. See http://www.jsunit.net/. There is a test runner online at http://www.jsunit.net/runner/testRunner.html.

The files xslt.html and xpath.html in the directory test are interactive tests. They can be run directly from the file system; no HTTP server is needed.

Both unit tests and interactive tests demonstrate the use of the library functions. There is not much more documentation so far.

CONFORMANCE

A few features that are required by the XSLT and XPath standards were left out. They are marked in the source code using alert() statements. See xslt.js.

The DOM implementation is minimal so as to support the XSLT processing, and not intended to be complete.

The implementation is all agnostic about namespaces. It just expects XSLT elements to have tags that carry the xsl: prefix, but we disregard all namespace declaration for them.

There are a few nonstandard XPath functions. Grep xpath.js for "ext-" to see their definitions.

BROWSER COMPATIBILITY

The library works in these browsers:

Remarks:

Safari/1.2 JavaScript is very slow, and apply larger stylesheets usually results in Safari freezing for a few seconds, and showing the beach ball.

Safari/2.0 has XSLT built in, but it is not exposed to JavaScript, but is only applied to XML documents that have a stylesheet declaration when they are loaded.

Internet Explorer exposes XSLT via the transformNode() method on the XML DOM. However, this is not avaiable if ActiveX is disabled.

Firefox exposes XSLT via the XSLTProcessor() object, and XPath in the document object in the DOM, so we don't need all this there.

The library probably still works in Opera/7.5, but we don't explicitly support this browser version anymore.

REFERENCES

[XPATH] XPath Specification http://www.w3.org/TR/1999/REC-xpath-19991116. [XSLT] XSLT Specification http://www.w3.org/TR/1999/REC-xslt-19991116. [DOM] W3C DOM Level 3 Core Specification http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/. [ECMA] ECMAScript Language Specification http://www.ecma-international.org/publications/standards/Ecma-262.htm.