BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
PHP XML
PHP XSLT Function xslt_set_error_handler
PHP XSLT Function xslt_setopt
PHP XSLT Function xslt_process
PHP XSLT Function xslt_getopt
PHP XSLT Function xslt_free
PHP XSLT Function xslt_error
PHP XSLT Function xslt_create
PHP SimpleXML Function New_Doc
PHP SimpleXML Function Save
PHP SimpleXML Function load_string
PHP SimpleXML Function Load_File
PHP SimpleXML Function LoadXML
PHP SimpleXML Function Load
PHP SimpleXML Function Open_File
PHP SimpleXML Function xml_parser_create
PHP SimpleXML Create an XML Document
PHP XML RPC Function Server Call method
PHP XML RPC Parse Method Descriptions
PHP XML RPC Function ServerCreate
PHP XML RPC Function GetType
 
 
 

By :Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :03/24/2008
Times viewed :254

 

PHP XSLT Function xslt_set_sax_handler

PHP Version: (4.0.3 - 4.0.6 only)

Description

This function sets sax handlers for xslt processor. You can provide handlers so that you can handle all SAX events. For more details on SAX events, please visit SAX tutorial on topxml.com.

Usage:

voidxslt_set_sax_handler ( resource xh, array handlers)

Set SAX handlers on the resource handle given by xh. SAX handlers should be a two dimensional array.

The structure of the array in the following format (all top level elements are optional):

array(

[document] =>

    array(

        start document handler,

        end document handler

    ),

[element] =>

    array(

        start element handler,

        end element handler

    ),

[namespace] =>

    array(

        start namespace handler,

        end namespace handler

    ),

[comment] => comment handler,

[pi] => processing instruction handler,

[character] => character data handler

)

PHP Code:

  <?php

//Here I have defined handler functions.

//start document function

functiondoc_start($xslt) {

    echo "<BR>Start document event encountered on '$xslt'";

}

//end document function.

functiondoc_end($xslt) {

    echo "<BR>End document encountered on '$xslt'";

}

// start element function.

functionelement_start($xslt_handle, $element, $attributes) {

    echo "<BR>Got element '$element'. ";

    if (count($attributes)) {

        echo "Attributes:";

        print_r($attributes);

    } else {

        echo "<BR>No attributes.";

    }

}

//I have skipped function for CDATA because, there is no CDATA in the XML

//Put all handlers in the two dimensional array.

$sax_handlers = array('document' => array('doc_start', 'doc_end'),

                      'element' => array('element_start'));

$processor = xslt_create();

//set the sax handler by passing all the sax handlers in the form of two //dimensional array.

xslt_set_sax_handler($processor, $sax_handlers);

//perform the transformation

$transformed = xslt_process($processor, 'employee.xml', 'employee.xsl');

//display the error messages. This line will not get executed because of error during transformation

echo $transformed;

//free the processor

xslt_free($processor);

?>


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

An immediate job opportunity as a B
Software Developers Needed in Charl
Sr. Software Engineer - Analytics
Immediate Mainframe openings for Ch
Immediate TANDEM-TAL openings for C

View all Jobs (Add yours)
View all CV (Add yours)



answering service
online fax
swimming pool contractor
conference calling services
water softener
Teleconference
Host Department NOLIMIT Web Hosting
MSN
sunglasses


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP