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

Re: removing nodes to parent based on all child nodes

Subject: Re: removing nodes to parent based on all child nodes not having text value
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 04 Dec 2008 07:34:21 -0500
Re:  removing nodes to parent based on all child nodes
At 2008-12-04 10:15 +0000, Vasu Chakkera wrote:
> <xsl:template match="node()|@*">
> <xsl:copy>
>  <xsl:apply-templates select="node()|@*"/>
> </xsl:copy>
> </xsl:template>
>
> <xsl:template match="*[not(descendant::text())]"/>
> </xsl:stylesheet>

That was not complete ..

The below is what i meant..

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>


<xsl:template match="*[not(descendant::text())]"/>

Be aware, Vasu, that her input data was indented, and you and I have proposed XSLT 1.0 results, and in that data model it is most likely (though not with Microsoft) that the white-space-only text nodes will all be present in the data model, thus your proposal will only get rid of empty leaf elements. Any other element will have indentation white-space-only text nodes. In a data fragment where there is a subtree of elements but no non-white-space-only text nodes, your stylesheet will preserve that tree rather than ignore it as I think the original poster wants.


And dealing with indentation is even more uncertain in XSLT 2.0 implementations where invocation options change the nature of the source tree presented to the stylesheet.

In all of my stylesheets I've very rarely ever needed to explicitly address text nodes, or the testing of element node values, without some qualification due to the uncertainty of indentation and of mixed content.

I hope this is considered helpful.

. . . . . . . . . . . Ken

--
Upcoming XSLT/XSL-FO, UBL and code list hands-on training classes:
:  Sydney, AU 2009-01/02; Brussels, BE 2009-03; Prague, CZ 2009-03
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video sample lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg
Video course overview:  http://www.youtube.com/watch?v=VTiodiij6gE
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

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-2011 All Rights Reserved.