# Class: XML::XSLT
[ "README", "AUTHORS", "COPYING", "ChangeLog", "lib/xml/xslt.rb", "ext/xslt_lib/xslt_lib.c", nil].each do
XML.view_html
XML::XSLT.view_html
XML::XSLT::TransformationError.view_html
XML::XSLT::ParsingError.view_html
XML::XSLT::XSLTError.view_html
end

Class XML::XSLT < Object

(in files lib/xml/xslt.rb ext/xslt_lib/xslt_lib.c )

Methods

Public Class method: new()

oXSLT = XML::XSLT::new()

Create a new XML::XSLT object

/** 
 * oXSLT = XML::XSLT::new()
 * 
 * Create a new XML::XSLT object
 */
VALUE ruby_xslt_new( VALUE class ) {

Public Class method: registerErrorHandler(&block)

registers a block to be called when libxml2 or libxslt encounter an error eg:

  XML::XSLT.registerErrorHandler do |error_str|
    $stderr.puts error_str
  end
    # File lib/xml/xslt.rb, line 67
67:     def self.registerErrorHandler(&block)
68:       @@error_handler = block
69:     end

Public Class method: registerExtFunc(namespace, name, &block)

sets up a block for callback when the XPath function namespace:name( … ) is encountered in a stylesheet.

  XML::XSLT.registerExtFunc(namespace_uri, name) do |*args|
    puts args.inspect
  end

XPath arguments are converted to Ruby objects accordingly:

number (eg. 1):Float
boolean (eg. false()):TrueClass/FalseClass
nodeset (eg. /entry/*):Array of REXML::Elements
variable (eg. $var):UNIMPLEMENTED

It works the same in the other direction, eg. if the block returns an array of REXML::Elements the value of the function will be a nodeset.

Note: currently, passing a nodeset to Ruby or REXML::Elements to libxslt serializes the nodes and then parses them. Doing this with large sets is a bad idea. In the future they‘ll be passed back and forth using Ruby‘s libxml2 bindings.

    # File lib/xml/xslt.rb, line 47
47:     def self.registerExtFunc(namespace, name, &block)
48:       @@extFunctions[namespace] ||= {}
49:       @@extFunctions[namespace][name] = block
50:       XML::XSLT.registerFunction(namespace, name)
51:     end

Public Class method: registerFunction(p1, p2)

internal use only.

/**
 * internal use only.
 */
 VALUE ruby_xslt_reg_function( VALUE class, VALUE namespace, VALUE name ) {

Public Instance method: mediaType()

mediaTypeString = oXSLT.mediaType( )

Return the XSL output‘s media type

/**
 * mediaTypeString = oXSLT.mediaType( )
 *
 * Return the XSL output's media type
 */
VALUE ruby_xslt_media_type( VALUE self ) {

Public Instance method: parameters=(p1)

oXSLT.parameters={ "key" => "value", "key" => "value", … }

/**
 * oXSLT.parameters={ "key" => "value", "key" => "value", ... } 
 */
VALUE ruby_xslt_parameters_set( VALUE self, VALUE parameters ) {

Public Instance method: save(p1)

oXSLT.save( "result.xml" )

Save the stylesheet transformation to file

/** 
 * oXSLT.save( "result.xml" ) 
 *
 * Save the stylesheet transformation to file
 */
VALUE ruby_xslt_save( VALUE self, VALUE xOutFilename ) {

Public Instance method: serve()

output_string = oXSLT.serve( )

Return the stylesheet transformation

/** 
 * output_string = oXSLT.serve( )
 *
 * Return the stylesheet transformation 
 */
VALUE ruby_xslt_serve( VALUE self ) {

Public Instance method: xml()

string = oXSLT.xml

Return XML, set by XML::XSLT#xml=, as string

/**
 * string = oXSLT.xml
 *
 * Return XML, set by XML::XSLT#xml=, as string
 */
VALUE ruby_xslt_xml_2str_get( VALUE self ) {

Public Instance method: xml=(p1)

oXSLT.xml=<data|REXML::Document|XML::Smart|file>

Set XML data.

Parameter can be type String, REXML::Document, XML::Smart::Dom or Filename

Examples :

 # Parameter as String
 oXSLT.xml = <<XML
 <?xml version="1.0" encoding="UTF-8"?>
 <test>This is a test string</test>
 XML

 # Parameter as REXML::Document
 require 'rexml/document'
 oXSLT.xml = REXML::Document.new File.open( "test.xml" )

 # Parameter as XML::Smart::Dom
 require 'xml/smart'
 oXSLT.xml = XML::Smart.open( "test.xml" )

 # Parameter as Filename
 oXSLT.xml = "test.xml"
/**
 * oXSLT.xml=<data|REXML::Document|XML::Smart|file>
 *
 * Set XML data.
 *
 * Parameter can be type String, REXML::Document, XML::Smart::Dom or Filename
 * 
 * Examples :
 *  # Parameter as String
 *  oXSLT.xml = <<XML
 *  <?xml version="1.0" encoding="UTF-8"?> 
 *  <test>This is a test string</test>
 *  XML
 *
 *  # Parameter as REXML::Document
 *  require 'rexml/document'
 *  oXSLT.xml = REXML::Document.new File.open( "test.xml" )
 *
 *  # Parameter as XML::Smart::Dom
 *  require 'xml/smart'
 *  oXSLT.xml = XML::Smart.open( "test.xml" )
 *
 *  # Parameter as Filename
 *  oXSLT.xml = "test.xml"
 */
VALUE ruby_xslt_xml_obj_set( VALUE self, VALUE xml_doc_obj ) {

Public Instance method: xmlfile=(p1)

XML::XSLT#xmlfile=<file> is deprecated. Please use XML::XSLT#xml=<file>

/**
 * XML::XSLT#xmlfile=<file> is deprecated. Please use XML::XSLT#xml=<file>
 */
VALUE ruby_xslt_xml_obj_set_d( VALUE self, VALUE xml_doc_obj ) {

Public Instance method: xmlobject()

object = oXSLT.xmlobject

Return the XML object set by XML::XSLT#xml=

/**
 * object = oXSLT.xmlobject
 *
 * Return the XML object set by XML::XSLT#xml=
 */
VALUE ruby_xslt_xml_2obj_get( VALUE self ) {

Public Instance method: xsl()

string = oXSLT.xsl

Return XSL, set by XML::XSLT#xsl=, as string

/**
 * string = oXSLT.xsl
 *
 * Return XSL, set by XML::XSLT#xsl=, as string
 */
VALUE ruby_xslt_xsl_2str_get( VALUE self ) {

Public Instance method: xsl=(p1)

oXSLT.xsl=<data|REXML::Document|XML::Smart|file>

Set XSL data.

Parameter can be type String, REXML::Document, XML::Smart::Dom or Filename

Examples :

 # Parameter as String
 oXSLT.xsl = <<XML
 <?xml version="1.0" ?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <xsl:apply-templates />
  </xsl:template>
 </xsl:stylesheet>
 XML

 # Parameter as REXML::Document
 require 'rexml/document'
 oXSLT.xsl = REXML::Document.new File.open( "test.xsl" )

 # Parameter as XML::Smart::Dom
 require 'xml/smart'
 oXSLT.xsl = XML::Smart.open( "test.xsl" )

 # Parameter as Filename
 oXSLT.xsl = "test.xsl"
/**
 * oXSLT.xsl=<data|REXML::Document|XML::Smart|file>
 *
 * Set XSL data.
 *
 * Parameter can be type String, REXML::Document, XML::Smart::Dom or Filename
 * 
 * Examples :
 *  # Parameter as String
 *  oXSLT.xsl = <<XML
 *  <?xml version="1.0" ?>
 *  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 *   <xsl:template match="/">
 *     <xsl:apply-templates />
 *   </xsl:template>
 *  </xsl:stylesheet>
 *  XML
 *
 *  # Parameter as REXML::Document
 *  require 'rexml/document'
 *  oXSLT.xsl = REXML::Document.new File.open( "test.xsl" )
 *
 *  # Parameter as XML::Smart::Dom
 *  require 'xml/smart'
 *  oXSLT.xsl = XML::Smart.open( "test.xsl" )
 *
 *  # Parameter as Filename
 *  oXSLT.xsl = "test.xsl"
 */
VALUE ruby_xslt_xsl_obj_set( VALUE self, VALUE xsl_doc_obj ) {

Public Instance method: xsl_to_s()

string = oXSLT.xsl_to_s( )

/** 
 * string = oXSLT.xsl_to_s( ) 
 */
VALUE ruby_xslt_to_s( VALUE self ) {

Public Instance method: xslfile=(p1)

XML::XSLT#xslfile=<file> is deprecated. Please use XML::XSLT#xsl=<file>

/**
 * XML::XSLT#xslfile=<file> is deprecated. Please use XML::XSLT#xsl=<file>
 */
VALUE ruby_xslt_xsl_obj_set_d( VALUE self, VALUE xsl_doc_obj ) {

Public Instance method: xslobject()

object = oXSLT.xslobject

Return the XSL object set by XML::XSLT#xsl=

/**
 * object = oXSLT.xslobject
 *
 * Return the XSL object set by XML::XSLT#xsl=
 */
VALUE ruby_xslt_xsl_2obj_get( VALUE self ) {