Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / July 2006

Tip: Looking for answers? Try searching our database.

XSLT : Exclude one NODE in Template

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ganesh Muthuvelu - 20 Jul 2006 14:36 GMT
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>

</xsl:stylesheet>
Martin Honnen - 20 Jul 2006 14:55 GMT
> 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..

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']" />

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.