Sha256: 7b5de25ad3c2c2fcb27de79ea4b635addbd627be55d9930272d6839b5fda87bc

Contents?: true

Size: 1.92 KB

Versions: 163

Compression:

Stored size: 1.92 KB

Contents

# frozen_string_literal: true

module Nokogiri
  module XSLT
    ###
    # A Stylesheet represents an XSLT Stylesheet object.  Stylesheet creation
    # is done through Nokogiri.XSLT.  Here is an example of transforming
    # an XML::Document with a Stylesheet:
    #
    #   doc   = Nokogiri::XML(File.read('some_file.xml'))
    #   xslt  = Nokogiri::XSLT(File.read('some_transformer.xslt'))
    #
    #   xslt.transform(doc) # => Nokogiri::XML::Document
    #
    # Many XSLT transformations include serialization behavior to emit a non-XML document. For these
    # cases, please take care to invoke the #serialize method on the result of the transformation:
    #
    #   doc   = Nokogiri::XML(File.read('some_file.xml'))
    #   xslt  = Nokogiri::XSLT(File.read('some_transformer.xslt'))
    #   xslt.serialize(xslt.transform(doc)) # => String
    #
    # or use the #apply_to method, which is a shortcut for `serialize(transform(document))`:
    #
    #   doc   = Nokogiri::XML(File.read('some_file.xml'))
    #   xslt  = Nokogiri::XSLT(File.read('some_transformer.xslt'))
    #   xslt.apply_to(doc) # => String
    #
    # See Nokogiri::XSLT::Stylesheet#transform for more information and examples.
    class Stylesheet
      # :call-seq:
      #   apply_to(document, params = []) -> String
      #
      # Apply an XSLT stylesheet to an XML::Document and serialize it properly. This method is
      # equivalent to calling #serialize on the result of #transform.
      #
      # [Parameters]
      # - +document+ is an instance of XML::Document to transform
      # - +params+ is an array of strings used as XSLT parameters, passed into #transform
      #
      # [Returns]
      #   A string containing the serialized result of the transformation.
      #
      # See Nokogiri::XSLT::Stylesheet#transform for more information and examples.
      def apply_to(document, params = [])
        serialize(transform(document, params))
      end
    end
  end
end

Version data entries

163 entries across 162 versions & 7 rubygems

Version Path
nokogiri-1.16.7-arm-linux lib/nokogiri/xslt/stylesheet.rb
nokogiri-1.16.7-aarch64-linux lib/nokogiri/xslt/stylesheet.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/nokogiri-1.16.6-arm64-darwin/lib/nokogiri/xslt/stylesheet.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/nokogiri-1.16.5-x86_64-linux/lib/nokogiri/xslt/stylesheet.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/nokogiri-1.16.5-x86_64-linux/lib/nokogiri/xslt/stylesheet.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/nokogiri-1.16.5-x86_64-linux/lib/nokogiri/xslt/stylesheet.rb
nokogiri-1.16.6 lib/nokogiri/xslt/stylesheet.rb
nokogiri-1.16.6-x86_64-linux lib/nokogiri/xslt/stylesheet.rb
nokogiri-1.16.6-x86_64-darwin lib/nokogiri/xslt/stylesheet.rb
nokogiri-1.16.6-x86-mingw32 lib/nokogiri/xslt/stylesheet.rb
nokogiri-1.16.6-x86-linux lib/nokogiri/xslt/stylesheet.rb
nokogiri-1.16.6-x64-mingw32 lib/nokogiri/xslt/stylesheet.rb
nokogiri-1.16.6-x64-mingw-ucrt lib/nokogiri/xslt/stylesheet.rb
nokogiri-1.16.6-java lib/nokogiri/xslt/stylesheet.rb
nokogiri-1.16.6-arm64-darwin lib/nokogiri/xslt/stylesheet.rb
nokogiri-1.16.6-arm-linux lib/nokogiri/xslt/stylesheet.rb
nokogiri-1.16.6-aarch64-linux lib/nokogiri/xslt/stylesheet.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/nokogiri-1.16.5-x86_64-linux/lib/nokogiri/xslt/stylesheet.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/nokogiri-1.16.5-x86_64-linux/lib/nokogiri/xslt/stylesheet.rb
nokogiri-1.16.4 lib/nokogiri/xslt/stylesheet.rb