[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Storing output tree in a variable and stripping

Subject: Storing output tree in a variable and stripping
From: hallo@xxxxxxxxxxxxx
Date: Tue, 19 Oct 2010 21:15:17 +0200
 Storing output tree in a variable and stripping
Hello,

I just investigated the possibility to store the output tree in a variable ...

<xsl:variable name="outputRaw">
 <xsl:apply-templates match="abc"/>
 <xsl:apply-templates match="def"/>
 ...
</xsl:variable>

... in order to strip away all empty elements without having (a) to create a separate stylesheet which would do this job or (b) complex if-then structures in order to prevent the creation of an empty element beforehand.

Below is the xslt-code which is responsible for selecting and displaying only non-empty nodes which had been created beforehand by the given templates and stored in the $outputRaw variable.

<xsl:for-each select="$outputRaw/*[text() | *]">
 <xsl:copy-of select="."/>
</xsl:for-each>

Although this solution seems to me pretty elegant in comparison to (a) a separate stylesheet or (b) if-then structures which would only bloat the xslt-code , I'm not quite sure if this solution is a good idea regarding the performance of the stylesheet.

I would be very thankful for any clues and advice.

Regards, Matthias

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.