Subject: Re: [xsl] [XSLT 1.0] Q: recursively eliminate empty nodes From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 08 Nov 2010 14:03:56 -0500 |
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())]" />
I was asked on how to do this until all empty nodes are gone, even the newly created empty nodes after removal of an inner empty node. The question was on whether this can be done without applying the stylesheet again and again. ... $ cat x.xml <a><b>c<c/></b><b><c/></b></a>
~/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="@*|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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Generating XSD Schema fil, Neil Owens | Thread | [xsl] Retrieving Complete XPATH fro, Ramkumar.V |
Re: [xsl] [XSLT 1.0] Q: recursively, David Carlisle | Date | Re: [xsl] [XSLT 1.0] Q: recursively, Andriy Gerasika |
Month |