Re: [SMARTY] output filters and XSL

From: Date: Wed, 21 Aug 2002 22:49:16 +0000
Subject: Re: [SMARTY] output filters and XSL
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5800@lists.php.net to get a copy of this message
Finally, i give up with the 'output filter' solution i decided to do like that include_once("path to Class.XSL.php"); $xsl = new XSL; include_once("path to Smarty.class.php"); $smarty = new Smarty; $xml_output=$smarty->fetch('path to test.xml.tpl'); $xsl_output=$smarty->fetch('path to test.xsl.tpl'); $xsl->transform($xml_output,$xsl_output); with Class.XSL.php: <? class XSL { function transform($xml,$xsl) { $arguments = array('/_xml' => $xml,'/_xsl' => $xsl); $xh = xslt_create(); $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); if ($result) print $result; else { print "Sorry, sample.xml could not be transformed by sample.xsl into"; print " the \$result variable the reason is that " . xslt_error($xh) . print " and the error code is " . xslt_errno($xh); } xslt_free($xh); } } ?> i do not think 'output filter' was made to achieve such XSL post processing
On Wed, Aug 21, 2002 at 11:10:44PM +0200, olivier hericord wrote:
i've made a XSL class that take in argument: -a XML file -a XSL file (that will determine the kind of output to build from the
XML    ...HTML or rtf or....)
Now my XML files are generated by Smarty. So i call my XSL class by an 'output filter' processing the XML file generated by Smarty.... My problem is that the 'XSL' file is hard coded into the output filter!!! Why??? Because i do not know how to give the output filter an argument!!!!! it would be so cool if i was able to write $smarty->load_filter('output', 'xslt','XSL_template/resa.xsl'); // load output filter named 'xslt' where the 3rd is the path to my XSL file...
you could assign a variable $smarty->assign('filter', 'resa.xsl') and then access $smarty->_tpl_vars['filter'] in your output-filter. this is not the cleanest way, since "_tpl_vars" is considered an "internal" variable, but it gets your job done. regards messju
PLEASE HELP ME!!! :)
-- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.smarty.general (#5800) next »