From: Peter Hickman Date: 2008-11-17T19:45:24+09:00 Subject: Problems passing parameters into XSLT I'm having some problems passing parameters into XSLT with ruby. The following script, based on the example in the docs ----- run.rb #!/usr/bin/ruby require 'rubygems' require 'xml' require 'xslt' # Create a new XSL Transform stylesheet_doc = LibXML::XML::Document.file('browse.xsl') stylesheet = LibXSLT::XSLT::Stylesheet.new(stylesheet_doc) # Transform a xml document xml_doc = LibXML::XML::Document.file('page.xml') result = stylesheet.apply(xml_doc, {:root => "ROOT", :back => "BACK"}) puts result Processes these two files ----- page.xml ----- browse.xsl

This is the value of root is

This is the value of back is

When run produces the following output: $ ./run.rb

This is the value of root is

This is the value of back is

$ As you can see the parameters 'root' and 'back' have not been filled in. When I run the data with xsltproc it works ok which would suggest that it is not a problem with the data or the stylesheet. $ xsltproc --stringparam root 'ROOT' --stringparam back 'BACK' browse.xsl page.xml

This is the value of root is ROOT

This is the value of back is BACK

$ Here is what I have: $ ruby -v ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] $ gem list *** LOCAL GEMS *** actionmailer (2.1.2) actionpack (2.1.2, 1.13.6) actionwebservice (1.2.6) activerecord (2.1.2, 1.15.6) activesupport (2.1.2, 1.4.4) acts_as_ferret (0.4.3) capistrano (2.0.0) cgi_multipart_eof_fix (2.5.0) daemons (1.0.10) dnssd (0.7.0) fastthread (1.0.1) fcgi (0.8.7) ferret (0.11.6) gem_plugin (0.2.3) highline (1.5.0) hpricot (0.6.164) json (1.1.3) libxml-ruby (0.8.3) libxslt-ruby (0.8.2) mongrel (1.1.5) needle (1.3.0) net-sftp (2.0.1) net-ssh (2.0.4) rails (2.1.2) rake (0.8.3) RedCloth (3.0.4) ruby-openid (2.1.2) ruby-yadis (0.3.4) rubynode (0.1.5) sqlite3-ruby (1.2.4) termios (0.9.4)