Nokogiri : XSLT Transform passing parameters

U

Une Bévue

I'm trying to pass one parameter to XSLT Transform, like that :
doc = Nokogiri::XML(File.read(find_latest_xml))
xslt = Nokogiri::XSLT(File.read("#{@sites_xml_fo}/#{@xsl_fbn}"))
puts xslt.transform(doc, ["lang", "fr"])

with the following styyle sheet :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
....
<xsl:param name="lang"/>
....
<h2>$lang = <xsl:value-of select="$lang"/></h2>

resulting in :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<h2>My Family Address Book</h2>
<h2>$lang = </h2>

that's to say the parameter is seen as empty, why ???

also, i'd like to pas more parameters, is it like that :

puts xslt.transform(doc, ["param-1", "value-1", ..., "param-n",
"value-n"])

???
 
U

Une Bévue

Le 29/01/12 15:59, Une Bévue a écrit :
that's to say the parameter is seen as empty, why ???

also, i'd like to pas more parameters, is it like that :

puts xslt.transform(doc, ["param-1", "value-1", ..., "param-n",
"value-n"])

put single quotes around string parameters :

["param-1", "'value-1'" ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top