Sha256: 2d6bc7d19c87132d0b9139ba80855a72f83ab7912d3912e7bc7471a1e09d5a97

Contents?: true

Size: 1.08 KB

Versions: 52

Compression:

Stored size: 1.08 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
      XSLT.parse(stylesheet)
    end
  end

  ###
  # See Nokogiri::XSLT::Stylesheet for creating and maniuplating
  # Stylesheet object.
  module XSLT
    class << self
      ###
      # Parse the stylesheet in +string+
      def parse string
        Stylesheet.parse_stylesheet_doc(XML.parse(string))
      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

52 entries across 52 versions & 8 rubygems

Version Path
nokogiri-1.5.0.beta.2 lib/nokogiri/xslt.rb
nokogiri-1.5.0.beta.2-java lib/nokogiri/xslt.rb
nokogiri-1.4.3.1-java lib/nokogiri/xslt.rb
nokogiri-1.4.3.1-x86-mswin32 lib/nokogiri/xslt.rb
nokogiri-1.4.3.1-x86-mingw32 lib/nokogiri/xslt.rb
nokogiri-1.4.3.1 lib/nokogiri/xslt.rb
nokogiri-1.4.3-java lib/nokogiri/xslt.rb
nokogiri-1.4.3-x86-mswin32 lib/nokogiri/xslt.rb
nokogiri-1.4.3-x86-mingw32 lib/nokogiri/xslt.rb
nokogiri-1.4.3 lib/nokogiri/xslt.rb
glebm-nokogiri-1.4.2.1 lib/nokogiri/xslt.rb
nokogiri-1.5.0.beta.1 lib/nokogiri/xslt.rb
nokogiri-1.4.2.1-x86-mswin32 lib/nokogiri/xslt.rb
nokogiri-1.4.2.1-x86-mingw32 lib/nokogiri/xslt.rb
nokogiri-1.5.0.beta.1-java lib/nokogiri/xslt.rb
nokogiri-1.4.2-java lib/nokogiri/xslt.rb
nokogiri-1.4.2 lib/nokogiri/xslt.rb
rubyjedi-nokogiri_java-1.4.0.20100513161003-java lib/nokogiri/xslt.rb
jwagener-nokogiri-1.4.1 lib/nokogiri/xslt.rb
akamai_bookmarklet-0.1.2 vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xslt.rb