XSLT_Processor

Wrapper class for the Sablotron XSLT extension

!!! REQUIRES Installed Sablotron to run !!!

Example:

$xslt = new XSLT_Processor;

$xslt->setXmlFile("foo.xml"); $xslt->setXslFile("bar.xslt");

$html = $xslt->process();

 Methods

Constructor

XsltProcessor() 

access private

Initialize the class

_init() : void

access private

Manual free of the parser

free() : void

Translate literal to numeric entities to avoid the 'undefined entity error' that a literal entity would cause.

literal2NumericEntities(string $stringXml) : string

access private

Parameters

$stringXml

string

XML String with literal entities

Returns

stringXML string with numeric entites

Prints the Error message and number if an error occured

printErrors() : void

access public

Transform the XML data using the XSL and return the results of the transformation

process() : string

access public

Returns

stringTransformed data

Return the contents of a file if the passed parameter is a file.

readFromFile(string $file) : string

access private

Parameters

$file

string

File location

Returns

stringFile contents

Pass top level parameters to the XSLT processor.

setParam(string $name, string $value) : void

The parameters can be accessed in XSL with

Parameters

$name

string

Name

$value

string

Value

Define external scheme handlers for the XSLT Processor.

setSchemeHandlers(array $aHandlers) : void

Example param array:

array("get_all", "mySchemeHandler")

Example scheme handler function:

function mySchemeHandler($processor, $scheme, $param) { // to remove the first slash added by Sablotron $param = substr($param, 1);

   if ($scheme == 'file_exists')
   {   // result is returned as valid xml string
   return '<?xml version="1.0" encoding="UTF-8"?><root>'.(file_exists($param) ? "true" : "false")."</root>";
}

}

To use the schema handler use: do something

To call the external function use the 'document()' XSLT-Function.

Schemename and parameter will be passed to the handler function as second and third parameter. The return value of the function must be valid XML to access it using XPath.

access public

Parameters

$aHandlers

array

array("scheme"=>"schemeHandlerName");

Set the XML to be Transformed

setXml(string $xml) : void

access public

Parameters

$xml

string

The XML String

Set the XML-File to be Transformed

setXmlFile(string $file) : void

access public

Parameters

$file

string

Location of the XML file

Set the XSLT for the Transformation

setXsl(string $xsl) : void

access public

Parameters

$xsl

string

The XML String

Set the XSL-File for the Transformation

setXslFile(string $file) : void

access public

Parameters

$file

string

Location of the XSL file

 Properties

 

XSLT Process arguments array

$arguments : array

access private
 

XSML Processor auto-free

$autofree : bool

access private
 

Error number

$errno : int

access private
 

Error message string

$error : string

access private
 

XSLT Process parameters array

$parameters : array

access private
 

XSLT Processor

$processor : object

access private
 

The result of the XSLT Transformation

$result : string

access private
 

The XML String for the Transformation

$xml : string

access private
 

The XSLT String for the Transformation

$xslt : string

access private