xml/xslt external function

Discussion in 'Ruby' started by Une Bévue, Feb 4, 2008.

  1. Une Bévue

    Une Bévue Guest

    i want to use an external ruby function "w3ready " within an xsl ssheet
    in order to transform a given text to unaccentuated.

    calling the function :

    <xsl:template match="/xCard">
    [...]
    <xsl:for-each select="GRPS/GRP/*">
    <xsl:variable name="group_label" select="text()"/>
    <xsl:variable name="page_name"
    select="ex:w3ready($group_label)"/>
    [...]

    part of the xml :

    <xCard>
    <GRPS>
    <GRP>AB2Web</GRP>
    <GRP>Amis</GRP>
    [...]
    <GRP>Santé</GRP>
    <GRP>Tourisme</GRP>
    <GRP>Vignerons</GRP>
    </GRPS>
    <vCard>
    <VERSION>2.0</VERSION>
    <ID>@uid</ID>
    <PHOTO>company.png</PHOTO>
    <GRP>Négociant</GRP>
    [...]

    the ruby function :

    def w3ready( label )
    puts "label = #{label}, label.class = #{label.class}"
    s = ""
    case( label.class.to_s )
    when "Array"
    s = label[ 0 ].u.www_ready
    when "String"
    s = label.u.www_ready
    end
    return s
    end

    i'm surprised here to get an Array instead of a String ( the reason for
    the case when...)

    #u.www_ready transforms "Maison de la Santé" into "maison_de_la_sante"
    in order to build a file name.

    the Array i get is of only one element...

    where is my mistake here ?
    --
    Une Bévue
     
    Une Bévue, Feb 4, 2008
    #1
    1. Advertising

  2. Une Bévue

    Tim Perrett Guest

    What XSLT parser are you using?
    Ive just done a load of XSLT work and im not sure this is possible??

    Cheers

    Tim
    --
    Posted via http://www.ruby-forum.com/.
     
    Tim Perrett, Feb 6, 2008
    #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. Stylus Studio
    Replies:
    0
    Views:
    770
    Stylus Studio
    Aug 3, 2004
  2. Replies:
    4
    Views:
    715
  3. jkflens
    Replies:
    2
    Views:
    1,546
    jkflens
    May 30, 2006
  4. Une Bévue
    Replies:
    0
    Views:
    639
    Une Bévue
    Jan 30, 2012
  5. Arne Pagel
    Replies:
    0
    Views:
    785
    Arne Pagel
    Jul 15, 2012
Loading...

Share This Page