[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Delete XML Node

Subject: RE: Delete XML Node
From: "KIENLE, STEVEN C [IT/0200]" <steven.c.kienle@xxxxxxxxxxxxx>
Date: Thu, 31 Oct 2002 14:27:42 -0500
RE:  Delete XML Node
Deepak,

In case what you really want to do is output Y if and only if it has a Z
element node, the following transform will work:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/X">
    <X>
      <xsl:for-each select="A">
        <A>
          <xsl:value-of select="."/>
        </A>
      </xsl:for-each>
      <xsl:for-each select="Y[Z]">
        <Y>
          <xsl:for-each select="Z">
            <Z>
              <xsl:value-of select="."/>
            </Z>
          </xsl:for-each>
        </Y>
      </xsl:for-each>
    </X>
  </xsl:template>
</xsl:stylesheet>

This key is to use the XPath selection of "Y[Z]" which means all Y which
have a Z element.

With the input XML of:

<X>
  <A>A</A>
  <Y></Y>
</X>

The output will be:

<X>
  <A>A</A>
</X>

With the input XML of:

<X>
  <A>A</A>
  <Y>
    <Z>B</Z>
  </Y>
</X>

The output will be:

<X>
  <A>A</A>
  <Y>
    <Z>B</Z>
  </Y>
</X>

I hope this may help.

	Steve

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.