Passing parameters through a Nokogiri XSLT Transform

To pass a parameter to Nokogiri#transform supply an array containing the variable name, and the value.


require 'nokogiri'

doc = Nokogiri::XML('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

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'])