2012-02-01 2 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

Welcome to Stackoverflow. http://stackoverflow.com/questions/how-to-ask를 읽어보십시오. –

답변

3

당신하여 XSLT 파일에 루비 기능을 사용할 수 있습니다 다음과 같은 함수 :

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