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
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);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.