W3cubDocs

/Nokogiri

module Nokogiri::XSLT

See Nokogiri::XSLT::Stylesheet for creating and manipulating Stylesheet object.

Public Class Methods

parse(string, modules = {}) Show source
# File lib/nokogiri/xslt.rb, line 24
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) Show source
# File lib/nokogiri/xslt.rb, line 39
def quote_params(params)
  parray = (params.instance_of?(Hash) ? params.to_a.flatten : params).dup
  parray.each_with_index do |v, i|
    parray[i] = if i % 2 > 0
      if /'/.match?(v)
        "concat('#{v.gsub(/'/, %q{', "'", '})}')"
      else
        "'#{v}'"
      end
    else
      v.to_s
    end
  end
  parray.flatten
end

Quote parameters in params for stylesheet safety

© 2008–2018 Aaron Patterson, Mike Dalessio, Charles Nutter, Sergio Arbeo,
Patrick Mahoney, Yoko Harada, Akinori MUSHA, John Shahid, Lars Kanis
Licensed under the MIT License.
https://nokogiri.org/rdoc/Nokogiri/XSLT.html