Re: Selecting and printing certain nodes
At 04:02 PM 2/19/2004, you wrote:
I am having a problem printing certain nodes to the result tree. Here is the XML I am working on:
That's a fair assumption. Since you don't have any <variable> elements, the test="name()='variable'" will never be true.
Beyond this, however, is a mystery. For one thing, as given your code won't work -- there's no assignment of a value to a variable $data; and it looks as though nothing will ever be assigned to $cdata either.
Which really raises the question of why you are writing a recursive template to do what the XSL processor will do for you in any case. Is there a reason why you aren't using the standard template-driven approach? If you want your output to look just like your input, the identity template provides for this:
<xsl:template match="node()"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template>
(In this case, the text will be copied to output by virtue of matching the built-in template for text nodes, which copies the value of the node to the result.)
But even if you don't want your output exactly like your input, plain-vanilla XSLT template matching is far easier and more flexible, too.
Please elucidate: we need more context for your code, both how it's getting invoked, and why you're doing it this way and not the easy way. :->
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