Groups | Blog | Home
all groups > dotnet xml > july 2006 >

dotnet xml : XSLT : Exclude one NODE in Template


Ganesh Muthuvelu
7/20/2006 6:36:02 AM
Hello all,
I want to exclude one node (element alone) but copy all of the other
elements. This is the XSLT I have. I want to exclude the "alias" element
alone but it does not work..

Can somebody help?

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

<xsl:template match="command">
<xsl:copy-of select="groupId"/>
<xsl:apply-templates select="serviceInstanceProfile"/>
<xsl:copy-of select="enableVideo"/>
</xsl:template>

<xsl:template match="serviceInstanceProfile">
<serviceInstanceProfile>
<xsl:copy-of select = "child::*[text()!='alias']"/>
</serviceInstanceProfile>
</xsl:template>

Martin Honnen
7/20/2006 3:55:54 PM


[quoted text, click to view]


[quoted text, click to view]

If you have elements named alias then simply do
<xsl:template match="alias" />
and use the identity transformation template.

If you have an element with the text content 'alias' then do
<xsl:template match="*[text() = 'alias']" />
and use the identity transformation template. Depending on white space
you might want
<xsl:template match="*[normalize-space(text()) = 'alias']" />

--

Martin Honnen --- MVP XML
AddThis Social Bookmark Button