Sha256: 339254a962eda0448162fd574a28aeb443893f4ec061ac005e6ec43cacc649d1

Contents?: true

Size: 1.39 KB

Versions: 61

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true
module Nokogiri
  class << self
    ###
    # Create a Nokogiri::XSLT::Stylesheet with +stylesheet+.
    #
    # Example:
    #
    #   xslt = Nokogiri::XSLT(File.read(ARGV[0]))
    #
    def XSLT stylesheet, modules = {}
      XSLT.parse(stylesheet, modules)
    end
  end

  ###
  # See Nokogiri::XSLT::Stylesheet for creating and manipulating
  # Stylesheet object.
  module XSLT
    class << self
      ###
      # Parse the stylesheet in +string+, register any +modules+
      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

      ###
      # Quote parameters in +params+ for stylesheet safety
      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 v =~ /'/
              "concat('#{v.gsub(/'/, %q{', "'", '})}')"
            else
              "'#{v}'"
            end
          else
            v.to_s
          end
        end
        parray.flatten
      end
    end
  end
end

require_relative "xslt/stylesheet"

Version data entries

61 entries across 61 versions & 4 rubygems

Version Path
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/nokogiri-1.12.5-x86_64-linux/lib/nokogiri/xslt.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/nokogiri-1.12.5-x86_64-linux/lib/nokogiri/xslt.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/nokogiri-1.12.5-x86_64-linux/lib/nokogiri/xslt.rb
nokogiri-1.12.5 lib/nokogiri/xslt.rb
nokogiri-1.12.5-x86_64-linux lib/nokogiri/xslt.rb
nokogiri-1.12.5-x86_64-darwin lib/nokogiri/xslt.rb
nokogiri-1.12.5-x86-mingw32 lib/nokogiri/xslt.rb
nokogiri-1.12.5-x86-linux lib/nokogiri/xslt.rb
nokogiri-1.12.5-x64-mingw32 lib/nokogiri/xslt.rb
nokogiri-1.12.5-java lib/nokogiri/xslt.rb
nokogiri-1.12.5-arm64-darwin lib/nokogiri/xslt.rb
nokogiri-1.12.4 lib/nokogiri/xslt.rb
nokogiri-1.12.4-x86_64-linux lib/nokogiri/xslt.rb
nokogiri-1.12.4-x86_64-darwin lib/nokogiri/xslt.rb
nokogiri-1.12.4-x86-mingw32 lib/nokogiri/xslt.rb
nokogiri-1.12.4-x86-linux lib/nokogiri/xslt.rb
nokogiri-1.12.4-x64-mingw32 lib/nokogiri/xslt.rb
nokogiri-1.12.4-java lib/nokogiri/xslt.rb
nokogiri-1.12.4-arm64-darwin lib/nokogiri/xslt.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/nokogiri-1.12.3-x86_64-linux/lib/nokogiri/xslt.rb