2005-07-03 ========== リハビリと ruby-xslt -------------------- Reference URI: http://lowreal.net/logs/2005/07/03/1 Written Time: 2005-07-03T01:47:08+09:00 Tags: web xml xslt ruby-xslt 使うと XSLT (XSL Transformations) から Ruby のメソッドを呼べるみたいなので、とても使ってみたい。(何をするか、はと もかく) ただ、ちょっと実装が残念な形。 class XML::XSLT def round_trip( arg ) arg end def type( arg ) arg.class.to_s endendxslt = XML::XSLT.new()xslt.xsl = "functions.xsl"xslt. xml = "test.xml"xslt.extFunction("roundTrip", "http://test.none", xslt, "round_tr ip")xslt.extFunction("type", "http://test.none", xslt, "type")俺としては Proc オブジェクトとか、ブロックを直接渡したい。すなわち次のように xslt.extFunction("roundTrip", "http://test.none/", xslt) do |arg| argend#または 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 endendxslt.set_ext_functions ("http://test.none", XSLTFunctions) # XSLTFunctions.new# この場合 XSLT から呼ぶ関 数名は Ruby でのメソッド名と同じになる。とか。# やはり Ruby は書いていて気持ちいい 。ちょっとどうでもいいけど、なんかこの PC 描画がおかしい。温度のせい? 再起動したらなおった? ちょっと時間おかないと分からない。 限りなく不安定な PC だ。グラフィックボードにもファンがついているから、グラフィックボードが暑くて困っ ているのかもしれない。しかしゲームのとき気にならない (or 症状が出ていない?) のは なぜだろう。最も影響うけやすそうなんだけど。