[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: "Dion Houston" <dionh@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 31 Oct 2002 11:02:53 -0800
xsl delete
Hi Deepak!

Perhaps I'm missing something, but... Your XSLT (reformatted for clarity)

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <X>
      <xsl:for-each select="X/A">
        <A>
          <xsl:value-of select="."/>
        </A>
      </xsl:for-each>
<!-- Comment this section out to not have a Y element -->
      <Y>
        <xsl:for-each select="X/Y/Z">
          <Z>
            <xsl:value-of select="."/>
          </Z>
        </xsl:for-each>
      </Y>
<!-- end of section -->
    </X>
  </xsl:template>
</xsl:stylesheet>

Is putting in a <Y> element because you're explicitly telling it to.  Just remove the section I commented to not output that element.

HTH!

Dion


-----Original Message-----
From: Deepak Rao [mailto:deepaksubs@xxxxxxxxxxx] 
Sent: Thursday, October 31, 2002 10:13 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Delete XML Node

Hi,

I am converting XML to XML using XSL. I am facing a problem as mentioned 
below. Can anyone pl help with writing a correct XSL for solving the 
problem.

Thanks,
Deepak

For e.g.

The Schema
----------
<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>

<xsd:element name='A' type='xsd:string'>
</xsd:element>

<xsd:element name='Z'>
  <xsd:complexType/>
</xsd:element>

<xsd:element name='Y'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref='Z'/>
   </xsd:sequence>
  </xsd:complexType>
</xsd:element>

<xsd:element name='X'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref='A'/>
    <xsd:element ref='Y'/>
   </xsd:sequence>
  </xsd:complexType>
</xsd:element>
</xsd:schema>

The input XML
-------------
<X>
    <A>A</A>
    <Y></Y>
</X>

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

The output is
-------------
<?xml version='1.0' ?>
<X>
<A>A</A>
<Y/>
</X>

But I desire the output
-----------------------
<?xml version='1.0' ?>
<X>
<A>A</A>
</X>

_________________________________________________________________
Get a speedy connection with MSN Broadband.? Join now! 
http://resourcecenter.msn.com/access/plans/freeactivation.asp


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


 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.