mail usprint this pagerss feed

www.liip.ch

Liip is hiring!

XMLReader and XSLT

Rob Richards (no blog yet :) ) came up with this neat idea about how to use XMLReader and XSLT together. This is especially useful, if your to-be-transformed document is huge and you don't want to or can't load that into memory.

His "trick" uses the possibility to call PHP functions from within XSLT and to get node-trees (generated with the XMLReader::expand method) as return values from them, which then can be further processed with XSLT. See the PHP code and the XSLT code for the full example.

With this approach you always will only have the expand()ed node-tree in memory and not the whole document, which can save you a lot of memory. Or even make it possible to parse that document at all, and still using XSLT for the fine control of the output.

Really nice to see how the different libxml2-based PHP extension can work together, even in a way I didn't think of before :)

Related Entries:
php xslcache extension by the New York Times
Added xslt profiling to PHP 5.3 and 6 CVS
Pimp up your XSLT transformation
Profile XSLT transformations within PHP
Calling PHP function from XSLT vs. native XSLT functions benchmark
Comments (2) |  Permalink

Comments

Adam Trachtenberg @ 25.03.2006 19:40 CEST
Love it!
Maarten Manders @ 26.03.2006 12:57 CEST
Nice!

add a comment

Your email adress will never be published.
Comment spam will be deleted!

For Spammers Only
Name*
E-Mail
URL
Comment*
Notify me via E-Mail when new comments are made to this entry
Remember me (needs cookies)