Jump to content

Archived

This topic is now archived and is closed to further replies.

w3evolutions

XSL and PHP

Recommended Posts

I am trying to use PHP's XSLTProcessor() to generate some html pages. All is working well until I found out that you can't include multiple xsl sheets as they get overwritten, like the example on php.net.

 

Just for reference, as of this writing, this function does not support importing multiple stylesheets. The following will output only the stylesheet transformation of the second imported sheet:

 

<?php

# LOAD XML FILE
$XML = new DOMDocument();
$XML->load( 'data.xml' );

# START XSLT
$xslt = new XSLTProcessor();

# IMPORT STYLESHEET 1
$XSL = new DOMDocument();
$XSL->load( 'template1.xsl' );
$xslt->importStylesheet( $XSL );

#IMPORT STYLESHEET 2
$XSL = new DOMDocument();
$XSL->load( 'template2.xsl' );
$xslt->importStylesheet( $XSL );

#PRINT
print $xslt->transformToXML( $XML );
?> 

 

the problem is I have the xsl files tempalted as:

 

Header

Content

Footer

 

which are to be included in the site_contianer.xsl.

 

I need to figure out a way to dynamically create an:

 

<xsl:include .. />

 

when I tried a str_replace() the transformation failed.

 

any ideas?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.