Example:
require 'nokogiri' doc = Nokogiri::XML(File.open('edinburgh_category_summary.xml','r').read) xslt = Nokogiri::XSLT(open('edinburgh_categories.xsl','r')) a = ['fun', '456'] out = xslt.transform(doc, a) puts out.to_xml.to_s
Resources:
- Class: Nokogiri::XSLT::Stylesheet [rubyforge.org]
- Transform an XML file using XSLT with Nokogiri [dzone.com]
- Supplying parameters to Ruby XSLT [dzone.com]
*update: 10-Nov-09 @ 11:06pm*
I've just discovered that Nokogiri#transform params need to be declared as a special type if the value is alphanumeric. e.g.
a = Nokogiri::XSLT.quote_params(['fun', 'aaa456'])
Resources:
- XSLT transform with params - nokogiri-talk | Google Groups [google.com]