2012-02-01 20 views
1

Ruby/NokogiriがXSLT内で外部関数の使用を実装しているかどうか知りたいです。Ruby/Nokogiri XSLT変換と外部関数

「はい」の場合、構文は何ですか?

<xsl:stylesheet xmlns:my="http://example.com/functions" extension-element-prefixes="my"> 

あなたはその後、使用することができます:ルート要素にこれを追加することを忘れないでください、XSLTファイルで

myfuncs = Class.new do 
    def func1(a, b) 
    # do processing here 
    end 
end 

Nokogiri::XSLT.register "http://example.com/functions", myfuncs 

+0

ようこそStackoverflow。 http://stackoverflow.com/questions/how-to-askを読んでみてください。 –

答えて

3

次の方法で、あなたのXSLTファイルにルビーの機能を使用することができますこのような関数:

<xsl:template match="p"> 
    <xsl:value-of select="my:func1(@a, @b)"/> 
</xsl:template>