XSLT Functions


You use eXtensible Stylesheet Language Transformations (XSLT) to restructure or transform XML data into various formats, such as HTML. You can format XML data using PHP, in accordance with the template provided by XSLT.

The PHP extension provides a processor-independent API to perform XSLT transformations, and provides an interface to various XSLT processors, such as Sablotron and Xalan. PHP 4.1.1, the XSLT extension, supports only the Sablotron processor.

You can download Sablotron processor from http://www.gingerall.com/

The functions provided by the PHP extension to perform XSLT transformations are:

  • xslt_backend_info() : Returns a string that contains information about the backend compilation settings. If no backend information is available, the xslt_backend_info() function returns an error string. The syntax of the xslt_backend_info() function is:

     string xslt_backend_info (void) 
  • xslt_backend_name() : Returns the name of the backend processor. The syntax of the xslt_backend_name() function is:

     string xslt_backend_name (void) 
  • xslt_backend_version() : Returns the version number of Sablotron. The syntax of the xslt_backend_version() function is:

     string xslt_backend_version (void) 
  • xslt_create() : Creates a new XSLT processor. The syntax of the xslt_create() function is:

     resource xslt_create (void) 
  • xslt_errno() : Returns an error number. The syntax of the xslt_errno() function is:

     int xslt_errno (resource) 
  • xslt_error() : Returns an error message that describes the error generated while processing the XSLT processor. The syntax of the xslt_error() function is:

     mixed xslt_error (resource) 
  • xslt_process() : Performs the XSLT transformation. The syntax of the xslt_process() function is:

     mixed  xslt_process (resource , string xml_container, string xsl_container [, string result_container [, array arguments [, array parameters]]]) 

In the above syntax, the containers refer to the filename containing the document to be processed . The result _container string refers to the filename for a transformed document.

  • xslt_set_base() : Sets the base Uniform Resource Identifier (URI) for XSLT transformations. The syntax of the xslt_set_base() function is:

     void xslt_set_base (resource x, string uri) 
  • xslt_set_encoding() : Sets the encoding for the parsing of XML documents. The xslt_set_encoding() function is used only when you compile the Sablotron processor as backend, with encoding support. The syntax of the xslt_set_encoding() function is:

     void xslt_set_encoding (resource x, string encoding) 
  • xslt_set_error_handler() : Sets an error handler function for an XSLT processor. The syntax of the xslt_set_errror_handler () function is:

     void xslt_set_error_handler (resource x, mixed handler) 
  • xslt_set_log() : Creates a file that stores the log messages. The log messages store information about the status of the XSLT processor. The syntax of the xslt_set_log() function is:

     void xslt_set_log (resource x, mixed logparam) 

In the above syntax, x is a variable that refers to the XSLT parameter, and logparam is a parameter that toggles logging on and off. You need to call the xslt_set_log() function with a Boolean parameter to enable message logging, as logging is disabled by default.

  • xslt_set_sax_handler() : Sets the SAX handlers for the XSLT processor. The syntax of the xslt_set_sax_handler() function is:

     void xslt_set_sax_handler ( resource x, array handlers) 
  • xslt_set_scheme_handler() : Sets the scheme handlers for an XSLT processor. The syntax of the xslt_set_scheme_handler () function is:

     void xslt_set_scheme_handlers ( resource processor, array handlers) 



Integrating PHP and XML 2004
Integrating PHP and XML 2004
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 51

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net