Sha256: 4ca5099a93e749b46c8a2db53c2294f974f1e5f8cd6ff488092a5ac04025e4ee

Contents?: true

Size: 1.33 KB

Versions: 29

Compression:

Stored size: 1.33 KB

Contents

require 'nokogiri/xslt/stylesheet'

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 maniuplating
  # 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

        if Nokogiri.jruby?
          Stylesheet.parse_stylesheet_doc(XML.parse(string), string)
        else
          Stylesheet.parse_stylesheet_doc(XML.parse(string))
        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|
          if i % 2 > 0
            parray[i]=
              if v =~ /'/
                "concat('#{ v.gsub(/'/, %q{', "'", '}) }')"
              else
                "'#{v}'";
              end
          else
            parray[i] = v.to_s
          end
        end
        parray.flatten
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 6 rubygems

Version Path
nokogiri-maglev--1.5.2 lib/nokogiri/xslt.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/lib/nokogiri/xslt.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/lib/nokogiri/xslt.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/lib/nokogiri/xslt.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/lib/nokogiri/xslt.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/lib/nokogiri/xslt.rb
ftl-0.2.0 vendor/bundle/gems/nokogiri-1.5.2/lib/nokogiri/xslt.rb
horseman-0.0.5 vendor/ruby/1.9.1/gems/nokogiri-1.5.2/lib/nokogiri/xslt.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/nokogiri-1.5.2/lib/nokogiri/xslt.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/nokogiri-1.5.2/lib/nokogiri/xslt.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/nokogiri-1.5.2/lib/nokogiri/xslt.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/nokogiri-1.5.2/lib/nokogiri/xslt.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/nokogiri-1.5.2/lib/nokogiri/xslt.rb
nokogiri-1.5.3.rc2-java lib/nokogiri/xslt.rb
nokogiri-1.5.3.rc2-x86-mingw32 lib/nokogiri/xslt.rb
nokogiri-1.5.3.rc2-x86-mswin32-60 lib/nokogiri/xslt.rb
nokogiri-1.5.3.rc2 lib/nokogiri/xslt.rb
nokogiri-1.5.2 lib/nokogiri/xslt.rb
nokogiri-1.5.2-x86-mswin32-60 lib/nokogiri/xslt.rb
nokogiri-1.5.2-x86-mingw32 lib/nokogiri/xslt.rb