module Nokogiri::XSLT
See Nokogiri::XSLT::Stylesheet for creating and manipulating Stylesheet object.
Public Class Methods
# File lib/nokogiri/xslt.rb, line 25
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 Parse the stylesheet in string, register any modules
quote_params(params) → Array Show source
# File lib/nokogiri/xslt.rb, line 49
def quote_params(params)
params.flatten.each_slice(2).with_object([]) do |kv, quoted_params|
key, value = kv.map(&:to_s)
value = if /'/.match?(value)
"concat('#{value.gsub(/'/, %q{', "'", '})}')"
else
"'#{value}'"
end
quoted_params << key
quoted_params << value
end
end Quote parameters in params for stylesheet safety. See Nokogiri::XSLT::Stylesheet.transform for example usage.
- Parameters
-
params(Hash, Array)XSLTparameters (key->value, or tuples of [key, value])
- Returns
-
Array of string parameters, with quotes correctly escaped for use with
XSLT::Stylesheet.transform
© 2008–2023 by Mike Dalessio, Aaron Patterson, Yoko Harada, Akinori MUSHA, John Shahid,
Karol Bucek, Sam Ruby, Craig Barnes, Stephen Checkoway, Lars Kanis, Sergio Arbeo,
Timothy Elliott, Nobuyoshi Nakada, Charles Nutter, Patrick MahoneyLicensed under the MIT License.
https://nokogiri.org/rdoc/Nokogiri/XSLT.html