downloads | documentation | faq | getting help | mailing lists | reporting bugs | sites | links | my 
search for in the  
view the version of this page
Last updated: Thu, 21 Aug 2003


(PHP 4 >= 4.0.6)

xslt_set_scheme_handlers --  Set the scheme handlers for the XSLT processor


void xslt_set_scheme_handlers ( resource processor, array handlers)


This function is currently not documented; only the argument list is available.

add a note add a note User Contributed Notes
ohlesbeauxjours at yahoo dot fr
21-Mar-2003 03:49
xslt_set_scheme_handlers is a powerful feature, derived from the Sablotron engine, which can help in various situations.

Briefly, it allows you to call any kind of PHP instruction, during the treatment of a stylesheet, through the XSLT document() function.

For example, here is an implementation of the "file_exists()" PHP function :

// Definition of the handler :
function mySchemeHandler($processor, $scheme, $rest) {
  $rest=substr($rest,1);    // to remove the first / automatically added by the engine
  if($scheme == 'file_exists')
    return '<?xml version="1.0" encoding="UTF-8"?><root>'.(file_exists($rest) ? "true" : "false")."</root>";
    // result is embedded in a small xml string

// Initialisation of the handler (the "get_all"  should be work in most cases) :
$SchemeHandlerArray = array();
$SchemeHandlerArray["get_all"] = "mySchemeHandler";

// Start the engine :
$params = array();
$xh = xslt_create();
$result = xslt_process($xh,"myFile.xml","myFile.xsl",NULL,array(),$params);
echo $result;

Then, inside the stylesheet, you can test whether a certain file exists with :
<xsl:if test="document('file_exists:anotherXMLfile.xml?/root='true'">
 < !-- bla bla bla -->

So finally, the principle is simple :
-    you define a scheme (here, I called it "file_exists")
-    you write the action associated to that scheme (in the mySchemeHandler function)
-    you embed the (probable) results in an XML string, that you return.
-    and in the stylesheet, you check : document('myPersonalURIscheme:myXPath')

You can imagine many other uses for the mySchemeHandler() function.

My framework is : PHP 4.2.3, Sablotron version 0.96, and Expat 1.95.5
Please note that some older version of PHP might require an additionnal parameter :
and you place your XML in $buffer, instead of returning it with return().


 Last updated: Thu, 21 Aug 2003
show source | credits | sitemap | mirror sites 
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by:
Last updated: Sat 01 Nov 2003 04:13:36 EST EST