[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Streamline xslt
On Wednesday, September 25, 2002, at 10:26 AM, Geoff wrote:
The first thought I had was use includes. Php includes won't work You might want to look at Sablotron's ablity to fetch named buffers into a transform using the Xpath document () function. So you set up your transform like this: $xh = xslt_create (); $header = /* PHP code which generates well-formed XML */ $footer = /* PHP code which generates well-formed XML */ /* Now place these items in an array we'll pass to xslt_process */ $args = array( "/header" => $header, "/footer" => $footer ); /* And any parameters your defining in your XSLT */ $params = array( "foo" => $untaintedFoo, "bar" => $untaintedBar ); $source = "/path/to/xml/file.xml"; // If this is user input, you did untaint it, didn't you? $xslt = "/path/to/xslt.xsl"; $result = xslt_process ($xh,$source,$xslt,NULL,$args,$params); if ($result) { echo $result; } else { /* error handling */ } Inside your XSLT, you'll do something like <xsl:template match="/"> <xsl:apply-templates select="document('arg:/header')" /> <xsl:apply-templates /> <xsl:apply-templates select="document('arg:/footer')" /> </xsl:template> This is also described in the user-comments for the xlst_process function on the PHP.net site. Things to remember are that you should probably have an assertion on $header and $footer to insure they are well-formed. Or use a trusted library/class to generate the XML strings. Catting together the XML is dicey unless you can near certain that you won't end up with a malformed XML string. In the case where I implemented this, $header and $footer referred to files in the file system, and the path to the file was contigent on the value of $_SERVER['REQUEST_URI'], so we had to assert that the file existed, and was well formed. ---- Bill Humphries <bill@xxxxxxxxx> http://www.whump.com/moreLikeThis/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|