Sha256: c25c39a9c04f60735dac0a16018db6ead1fe6a1dc3bf8fbfd7d768bdc37e6ef3

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 KB

Contents

require 'sync'

require 'xml/xslt'

module Nitro

# Apply XSL transformation.

class XSLTransform
    @@sync = Sync.new

  class << self

    # The xslt filename.
    
    attr :xsl_filename
    
    # The xslt transformer.
    
    attr :xslt
  
    def initialize(xsl_filename, next_stage = nil)

      # leave this require here. only inlcude the xslt 
      # library if the project needs it.
      
      require "xml/xslt"

      @name = File.basename(xsl_filename, '.*')
      @xsl_filename = xsl_filename
      @xslt = XML::XSLT.new
      @next_stage = next_stage
    end
    
    # Transform the given xml.
    
    def transform(text)
      
      parse_xsl()
      @xslt.xml = text
      hash += @name
      Logger.debug "Applying xsl '#{@xsl_filename}' to template" if $DBG
      process_next(hash, xslt.serve)
    end
    
    private 
    
    # Parse the xsl.
    
    def parse_xsl
      Logger.debug "Parsing xsl '#{@xsl_filename}'" if $DBG
      @mtime = File.mtime(@xsl_filename)
      @xslt.xsl = File.read(@xsl_filename)
    end  
  end
  
end

end

# * George Moschovitis <gm@navel.gr>

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
nitro-0.21.0 lib/nitro/compiler/xslt.rb
nitro-0.21.2 lib/nitro/compiler/xslt.rb
nitro-0.22.0 lib/nitro/compiler/xslt.rb
nitro-0.23.0 lib/nitro/compiler/xslt.rb
nitro-0.24.0 lib/nitro/compiler/xslt.rb
nitro-0.25.0 lib/nitro/compiler/xslt.rb
nitro-0.26.0 lib/nitro/compiler/xslt.rb
nitro-0.27.0 lib/nitro/compiler/xslt.rb
nitro-0.28.0 lib/nitro/compiler/xslt.rb
nitro-0.29.0 lib/nitro/compiler/xslt.rb