/** * xslTransform * Tools for XSLT transformations; jQuery wrapper for Sarissa . * See jQuery.fn.log below for documentation on $.log(). * See jQuery.fn.getTransform below for documention on the $.getTransform(). * See var DEBUG below for turning debugging/logging on and off. * * @version 20071214 * @since 2006-07-05 * @copyright Copyright (c) 2006 Glyphix Studio, Inc. http://www.glyphix.com * @author Brad Brizendine , Matt Antone * @license MIT http://www.opensource.org/licenses/mit-license.php * @requires >= jQuery 1.0.3 http://jquery.com/ * @requires jquery.debug.js http://jquery.glyphix.com/ * @requires >= sarissa.js 0.9.7.6 http://sarissa.sourceforge.net/ * * @example * var r = $.xsl.transform('path-to-xsl.xsl','path-to-xml.xml'); * @desc Perform a transformation and place the results in var r * * @example * var r = $.xsl.transform('path-to-xsl.xsl','path-to-xml.xml'); * var str = $.xsl.serialize( r ); * @desc Perform a transformation, then turn the result into a string * * @example * var doc = $.xsl.load('path-to-xml.xml'); * @desc Load an xml file and return a parsed xml object * * @example * var xml = 'bar'; * var doc = $.xsl.load(xml); * @desc Load an xml string and return a parsed xml object */ (function($){ /* * JQuery XSLT transformation plugin. * Replaces all matched elements with the results of an XSLT transformation. * See xslTransform above for more documentation. * * @example * @desc See the xslTransform-example/index.html * * @param xsl String the url to the xsl file * @param xml String the url to the xml file * @param options Object various switches you can send to this function * + params: an object of key/value pairs to be sent to xsl as parameters * + xpath: defines the root node within the provided xml file * + eval: if true, will attempt to eval javascript found in the transformed result * + callback: if a Function, evaluate it when transformation is complete * @returns */ $.fn.getTransform = function( xsl, xml, options ){ var settings = { params: {}, // object of key/value pairs ... parameters to send to the XSL stylesheet xpath: '', // xpath, used to send only a portion of the XML file to the XSL stylesheet eval: true, // evaluate