Object
registers a block to be called when libxml2 or libxslt encounter an error eg:
XML::XSLT.registerErrorHandler do |error_str| $stderr.puts error_str end
# File lib/xml/xslt.rb, line 67 def self.registerErrorHandler(&block) @@error_handler = block end
sets up a block for callback when the XPath function namespace:name( … ) is encountered in a stylesheet.
XML::XSLT.registerExtFunc(namespace_uri, name) do |*args| puts args.inspect end
XPath arguments are converted to Ruby objects accordingly:
number (eg. 1) |
Float |
boolean (eg. false()) |
TrueClass/FalseClass |
nodeset (eg. /entry/*) |
Array of REXML::Elements |
variable (eg. $var) |
UNIMPLEMENTED |
It works the same in the other direction, eg. if the block returns an array of REXML::Elements the value of the function will be a nodeset.
Note: currently, passing a nodeset to Ruby or REXML::Elements to libxslt serializes the nodes and then parses them. Doing this with large sets is a bad idea. In the future they’ll be passed back and forth using Ruby’s libxml2 bindings.
# File lib/xml/xslt.rb, line 47 def self.registerExtFunc(namespace, name, &block) @@extFunctions[namespace] ||= {} @@extFunctions[namespace][name] = block XML::XSLT.registerFunction(namespace, name) end
Generated with the Darkfish Rdoc Generator 2.