![]() |
# 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 |

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

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
[ show source ]
# File lib/xml/xslt.rb, line 67
67: def self.registerErrorHandler(&block)
68: @@error_handler = block
69: end

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.
[ show source ]
# 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

internal use only.
[ show source ]
/**
* internal use only.
*/
VALUE ruby_xslt_reg_function( VALUE class, VALUE namespace, VALUE name ) {

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

oXSLT.parameters={ "key" => "value", "key" => "value", … }
[ show source ]
/**
* oXSLT.parameters={ "key" => "value", "key" => "value", ... }
*/
VALUE ruby_xslt_parameters_set( VALUE self, VALUE parameters ) {

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

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

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

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"
[ show source ]
/**
* 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 ) {

XML::XSLT#xmlfile=<file> is deprecated. Please use XML::XSLT#xml=<file>
[ show source ]
/**
* 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 ) {

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

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

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"
[ show source ]
/**
* 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 ) {

string = oXSLT.xsl_to_s( )
[ show source ]
/**
* string = oXSLT.xsl_to_s( )
*/
VALUE ruby_xslt_to_s( VALUE self ) {

XML::XSLT#xslfile=<file> is deprecated. Please use XML::XSLT#xsl=<file>
[ show source ]
/**
* 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 ) {

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