Nokogiri : XSLT Transform passing parameters

Discussion in 'Ruby' started by Une Bévue, Jan 29, 2012.

  1. Une Bévue

    Une Bévue Guest

    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, Jan 29, 2012
    #1
    1. Advertising

  2. Une Bévue

    Une Bévue Guest

    SOLVED : Nokogiri : XSLT Transform passing parameters

    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'" ...
     
    Une Bévue, Jan 29, 2012
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Benjamin Hillsley
    Replies:
    3
    Views:
    1,692
    Dimitre Novatchev
    Sep 25, 2003
  2. David
    Replies:
    1
    Views:
    733
    Martin Honnen
    Apr 3, 2004
  3. Alex Vinokur
    Replies:
    5
    Views:
    611
    Alex Vinokur
    Nov 4, 2003
  4. Peter Hickman

    Problems passing parameters into XSLT

    Peter Hickman, Nov 17, 2008, in forum: Ruby
    Replies:
    2
    Views:
    132
    Jamie Orchard-hays
    Jan 15, 2009
  5. Une Bévue
    Replies:
    0
    Views:
    613
    Une Bévue
    Jan 30, 2012
Loading...

Share This Page