|
Subject: Re: [xsl] Empty elements From: Ingo Schildmann <Ingo.Schildmann@xxxxxxxxxxxxx> Date: Fri, 22 Feb 2002 16:48:03 +0100 |
On Thursday 21 February 2002 18:47, you wrote:
> I've got a document that looks similar to below:
>
> <message_wrapper>
> <msg_header>
> <token>a token</token>
> <language>a language</language>
> </msg_header
> <msg_body>
> <group>
> <element1>value 1</element1>
> <element2>value 2</element2>
> </group>
> <group>
> <element1>value 3</element1>
> <element2>value 4</element2>
> </group>
> <group>
> <element1></element1>
> <element2></element2>
> </group>
> <group>
> <element1></element1>
> <element2></element2>
> </group>
> </msg_body>
> </message_wrapper>
>
> How can I remove the empty groups ?
> message_wrapper & msg_body will always have the same names, but the names
> of the group & element* elements will not always be the same.
The whitespace in the groups may be problematic. As long as a group is
considered empty if the value of all elements is only whitespace, too,
you could try this:
use the generic copy template:
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
and add a template which matchs the elements whose stringvalue is only
whitespace and does nothing.
<xsl:template match="*[not(normalize-space())]" />
--
Ingo Schildmann
Development
WiredMinds Informationssysteme GmbH
email: Ingo.Schildmann@xxxxxxxxxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] repost - string compariso, Kirk Allen Evans | Thread | [xsl] PI of xml-stylesheet doesn't , Kang Jeong-Hee |
| Re: [xsl] memory leak problem with , Thomas B. Passin | Date | [xsl] Boolean expr in <xsl:when>, Schmoll, Brett |
| Month |