Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Nokogiri : XSLT Transform passing parameters

301 views
Skip to first unread message

Une Bévue

unread,
Jan 29, 2012, 9:59:15 AM1/29/12
to
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"])

???

--
« Tel n'a de chaleur pour ses amis, que pour les brûler. »
(Proverbe arabe)

Une Bévue

unread,
Jan 29, 2012, 10:15:05 AM1/29/12
to
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'" ...
0 new messages