[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: [XSLT 1.0] Q: recursively eliminate empty nodes
At 2010-11-08 19:22 +0100, Hermann Stamm-Wilbrandt wrote:
I was given an identity transformation that eliminates empty nodes. <!-- identity template --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()" /> </xsl:copy> </xsl:template> <xsl:template match="*[not(node())]" /> Are you defining, then, an "ultimately" empty node as being a node that doesn't have descendent text nodes? If not, then please clarify with more examples. The code below gives you what your recursive solution gives you, but I can't tell from your specification if that is what you really want. Perhaps you are simply looking too deep at the problem? I hope this helps. . . . . . . . . . Ken ~/t/ftemp $ cat hermann.xml <a><b>c<c/></b><b><c/></b></a> ~/t/ftemp $ xslt hermann.xml hermann.xsl <?xml version="1.0" encoding="utf-8"?><a><b>c</b></a> ~/t/ftemp $ cat hermann.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="*[not(.//text())]"/> <xsl:template match="@*|node()"><!--identity for all other nodes--> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> ~/t/ftemp $ -- Contact us for world-wide XML consulting & instructor-led training Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|
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
|