module Nokogiri::XSLT
def parse(string, modules = {})
# "\n"
# "
# "
# "
# => "\n" +
xsl.transform(xml).to_xml
xsl = Nokogiri.XSLT(xsl, "http://nokogiri.org/xslt/myfuncs" => handler)
XSL
extension-element-prefixes="myfuncs">
xmlns:myfuncs="http://nokogiri.org/xslt/myfuncs"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
end
end
node.text.reverse
def reverse(node)
handler = Class.new do
XML
xml = Nokogiri.XML(<<~XML)
*Example*
Also see Nokogiri::XSLT.register
⚠ The XSLT handler classes are registered *globally*.
namespace to a custom function handler.
- +modules+ (Hash
- +xsl+ (String) XSL content to be parsed into a stylesheet
[Parameters]
Parse the stylesheet in +xsl+, registering optional +modules+ as custom class handlers.
parse(xsl, modules) → Nokogiri::XSLT::Stylesheet
parse(xsl) → Nokogiri::XSLT::Stylesheet
:call-seq:
def parse(string, modules = {}) modules.each do |url, klass| XSLT.register(url, klass) end doc = XML::Document.parse(string, nil, nil, XML::ParseOptions::DEFAULT_XSLT) if Nokogiri.jruby? Stylesheet.parse_stylesheet_doc(doc, string) else Stylesheet.parse_stylesheet_doc(doc) end end