ruby-xslt 使うと XSLT から Ruby のメソッドを呼べるみたいなので、とても使ってみたい。(何をするか、はともかく)

ただ、ちょっと実装が残念な形。

class XML::XSLT
def round_trip( arg )
arg
end
def type( arg )
arg.class.to_s
end
end
xslt = XML::XSLT.new()
xslt.xsl = "functions.xsl"
xslt.xml = "test.xml"
xslt.extFunction("roundTrip", "http://test.none", xslt, "round_trip")
xslt.extFunction("type", "http://test.none", xslt, "type")

俺としては Proc オブジェクトとか、ブロックを直接渡したい。すなわち次のように

xslt.extFunction("roundTrip", "http://test.none/", xslt) do |arg|
arg
end
#または
round_trip = lambda {|arg| arg}
xslt.extFunction("roundTrip", "http://test.none", xslt, round_trip)
# あるいはまとめたクラス / インスタンスを登録する形。
# もとのヤツに似ているけど名前が衝突しない。
class XSLTFunctions
def round_trip(arg)
arg
end
def type(arg)
arg.class.to_s
end
end
xslt.set_ext_functions("http://test.none", XSLTFunctions) # XSLTFunctions.new
# この場合 XSLT から呼ぶ関数名は Ruby でのメソッド名と同じになる。とか。
# やはり Ruby は書いていて気持ちいい。

ちょっとどうでもいいけど、なんかこの PC 描画がおかしい。温度のせい?

再起動したらなおった? ちょっと時間おかないと分からない。

限りなく不安定な PC だ。グラフィックボードにもファンがついているから、グラフィックボードが暑くて困っているのかもしれない。しかしゲームのとき気にならない (or 症状が出ていない?) のはなぜだろう。最も影響うけやすそうなんだけど。

  1. トップ
  2. web
  3. リハビリと ruby-xslt
  1. トップ
  2. xml
  3. リハビリと ruby-xslt
  1. トップ
  2. xslt
  3. リハビリと ruby-xslt
▲ この日のエントリ