Jump to content

XSL(T) Problem with Complex Elements


coderich

Recommended Posts

Hey gang, I hope I have chosen the correct forum for this post - if not I truly apologize.

 

I'm having trouble transforming a complex element. Everywhere I research it's stated that the solution is to use 'copy-of', and from the examples I see it does exactly what I want. The only problem is when I try to use it the order of my nested elements are output at the very end. I'm trying to transform elements that contain text and any number of other elements... right now I'm at a loss... any advice would be greatly appreciated.

 

Example:

 

xml

<text>This is <b>my</b> complex element <i>example</i></text>

xsl

<xsl:template match="text">
<xsl:copy-of select="node()"/>
</xsl:template>

The output I get

This is complex element<b>my</b><i>example</i>

The output I want

This is <b>my</b> complex element <i>example</i>

Link to comment
https://forums.phpfreaks.com/topic/93264-xslt-problem-with-complex-elements/
Share on other sites

*Booomf...*

 

I realize its probably more accurate to say "Mixed XML Element" But the problem still remains. I'm using PHP 5.2.5 - my transformation logic looks like this:

$xslt 	= new XSLTProcessor();
$xsl 	= new domDocument();
$xml	= new domDocument();

$xsl	-> load($xsl_file);
$xml	-> loadXML($xml_string);
$xslt	-> importStylesheet($xsl);

return $xslt->transformToXml($xml);

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.