Jump to content

XSL and PHP


w3evolutions

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?

Link to comment
https://forums.phpfreaks.com/topic/182004-xsl-and-php/
Share on other sites

Archived

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

×
×
  • Create New...

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.