# -*- encoding: utf-8 -*-
require "helper"
module Nokogiri
module XSLT
class TestCustomFunctions < Nokogiri::TestCase
def setup
super
@xml = Nokogiri.XML(<<-EOXML)
Foo
Foo
Lorem ipsum.
EOXML
end
def test_function
skip("Pure Java version doesn't support this feature.") if !Nokogiri.uses_libxml?
foo = Class.new do
def capitalize nodes
nodes.first.content.upcase
end
end
XSLT.register "http://e.org/functions", foo
xsl = Nokogiri.XSLT(<<-EOXSL)
EOXSL
result = xsl.transform @xml
assert_equal 'FOO', result.css('title').first.text
end
def test_function_XSLT
skip("Pure Java version doesn't support this feature.") if !Nokogiri.uses_libxml?
foo = Class.new do
def america nodes
nodes.first.content.upcase
end
end
xsl = Nokogiri.XSLT(<<-EOXSL, "http://e.org/functions" => foo)
EOXSL
result = xsl.transform @xml
assert_equal 'FOO', result.css('title').first.text
end
end
end
end