Documentation automatically generated from the source-code using phpDocumentor.
Official Homepage: xao-php.sourceforge.net
XAO
Official homepage | API home | class tree: XAO | index: XAO | all elements

Class: Transformer

Source Location: Program_Root/XAO_Transformer.php

Class Transformer

Class Overview

Utility performing XSLT transformations

This class encapsulates comprehensive XSLT functionality. It makes available multiple (pluggable) transformation engines through a unified, simplified API.

Located in Program_Root/XAO_Transformer.php [line 49]

XaoRoot
   |
   --Transformer
Author(s):
  • Terence Kearns
Information Tags:
Link:  http://xao-php.sourceforge.net
License:  LGPL
Copyright:  Terence Kearns 2003
Version:  0.0

Properties

Methods

[ Top ]
Property Summary
array   $arrXslParams   List of XSL parameters to be passed to the XSLT processor
node   $ndSrcRoot   Root element of source document object
node   $ndStyleRoot   Root element of source document object
object   $objSrc   DOM XML object instance of the source document
object   $objStyle   DOM XML object instance of stylsheet used in transformation
string   $strXsltProcessor   Which XSLT processor to use
string   $strXsltResult   XSLT processing result container
mixed   $_uriStyleSheet  

[ Top ]
Method Summary
void   Transformer()   Transformer constructor
void   SetXslParam()  
void   Throw()  
string   Transform()   Transform contents using stylsheet in $this->_uriStylSheet
void   _SablotronErrorTrap()  

[ Top ]
Properties
array   $arrXslParams = array() [line 110]

List of XSL parameters to be passed to the XSLT processor

Usually these will be set by the application class which inherits DomDoc. The transform methods of this class should use this associative array to add these parameters to the processor. WARNING: RELYING ON THIS METHOD OF SETTING XSL PARAMS WILL MAKE YOUR STYLSHEET INCOMPATIBLE WITH CLIENT-SIDE TRANSFORMATION. IMPORTANT NOTE: YOUR PARAMS WILL NOT BE AVAILABLE IN YOUR STYLSHEET IF YOU DO NOT DECLARE THEM (WITH EMPTY VALUES). THE PROCESSOR WILL ONLY FEED PARAM VALUES TO THE STYLESHEET BY OVERRIDING THE VALUES OF EXISTING ONES.

API Tags:
Access:  public


[ Top ]
node   $ndSrcRoot [line 70]

Root element of source document object

API Tags:
Access:  public


[ Top ]
node   $ndStyleRoot [line 91]

Root element of source document object

API Tags:
Access:  public


[ Top ]
object   $objSrc [line 62]

DOM XML object instance of the source document

This has to be specified in the constructor. The Transformer class will not work without this object and a DOM XML instnace of the stylsheet. The constructor may need to ensure this object eventuates by parsing in external XML data - same applies for the stylesheet.

API Tags:
Access:  public


[ Top ]
object   $objStyle [line 83]

DOM XML object instance of stylsheet used in transformation

This has to be specified in the constructor. The Transformer class will not work without this object and a DOM XML instnace of the source doc. The constructor may need to ensure this object eventuates by parsing in external XML data - same applies for the source doc.

API Tags:
Access:  public


[ Top ]
string   $strXsltProcessor = "DOMXML" [line 126]

Which XSLT processor to use

This option allows the user to choose which implemented XSLT processor to employ. At this stage, possible choices are:

  • SABLOTRON which uses the xslt_ functions built into PHP.
  • DOMXML which uses the experimental transformation capabilities of the native PHP domxml extension itself.
Future implementations could use external procesors which may be Java, Com, or command-line executables.

API Tags:
Access:  public


[ Top ]
string   $strXsltResult [line 137]

XSLT processing result container

Regardless of which XSLT processor is used, the result is always stored in this variable AS A STRING.

API Tags:
Access:  public


[ Top ]
mixed   $_uriStyleSheet [line 93]

[ Top ]
Methods
Constructor Transformer  [line 156]

  void Transformer( mixed &$mxdSrc, mixed &$mxdStyle  )

Transformer constructor

The main job here is to parse the source XML and the XSLT as DOM XML objects. Note that this technique incurs unneccesary overhead for tranform processors like sablotron. But this is neccesary to maintain the simplicity of the API - it's a trade-off! The stylesheet and the XML source can be supplied in one of three formats: 1) DOM XML object (preferrred) 2) file URI 3) well formed ascii data

Parameters:
mixed   &$mxdSrc:  starting XML source data
mixed   &$mxdStyle:  starting stylsheet

API Tags:
Access:  public


[ Top ]
SetXslParam  [line 266]

  void SetXslParam( mixed $strName, mixed $strValue  )



[ Top ]
Throw  [line 251]

  void Throw( mixed $strErrMsg, [mixed $arrAttribs = null]  )



Redefinition of:
XaoRoot::Throw()
Generic/default error handler.

[ Top ]
Transform  [line 300]

  string Transform( )

Transform contents using stylsheet in $this->_uriStylSheet

This function calls the Transformer class which takes a DomDoc in the first argument to the constructor as a reference. The Transformer object records any errors using the passed DomDoc's Throw() method (so the errors are bound to that source document). This function makes some decisions on how errors are released based on options set in $this DomDoc instance. Since a transformation result isn't always well-formed XML, the result is returned as a string. Here are the steps taken: 1) check for the existance of a stylsheet 2) route the request to the chosen XSLT processor member function 3) return the result.


API Tags:
Return:  The contents of the transformation result or false on failure
Access:  public


[ Top ]
_SablotronErrorTrap  [line 494]

  void _SablotronErrorTrap( mixed $resSab, mixed $intSabErr, mixed $strSabLvl, mixed $arrSabErrData  )



[ Top ]

Documentation generated on Tue, 23 Sep 2003 18:34:10 +1000 by phpDocumentor 1.2.2