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

Commenting selected elements (parents) and keeping the

Subject: Commenting selected elements (parents) and keeping the child elements with attributes/restoring parents elements somewhere else
From: "Pankaj Chaturvedi" <pankaj.chaturvedi@xxxxxxxxx>
Date: Fri, 9 May 2008 13:31:09 +0530
 Commenting selected elements (parents) and keeping the
Hello all,

Is there is a way to commenting some specific elements mostly parents while
retaining the child elements in output. I know I am sounding bit stupid as
far as the hierarchy of xml is concerns, but I need to restore the
parents/grand parents (instead omitting them) along with their attribute
values.


As of now I am trying the following, but its omit them.



	<xsl:template match="root">
<xsl:copy>
<xsl:attribute name="dummy">the_root</xsl:attribute>
			<xsl:apply-templates/>
			<xsl:apply-templates select=".//aaa"/>
	</xsl:copy>
	</xsl:template>


	<xsl:template match="root//aaa">
      <xsl:copy>
		<xsl:attribute name="dummy">xxx</xsl:attribute>
			<xsl:copy-of select="@*"/>
			<xsl:apply-templates/>
	</xsl:copy>
	</xsl:template>


  <!-- omit these -->

 <xsl:template match="abc | bbb"/>




Input
====
<root>
	<abc id="123">
		<bbb>
			<aaa id="123">xxxxxx</aaa>
		</bbb>
		<abc>
</root>


Output
======

<root>
<!--<abc id="123"><bbb>-->
			<aaa id="123">xxxxxx</aaa>
<!--</bbb>
		<abc>-->

</root>

or may be something like
===================

<root>
			<aaa id="123">xxxxxx</aaa>

	<!--<abc id="123">
<bbb>--><!--</bbb>
<abc>-->

</root>


I've also tried to use the following but takes only text nodes of the <abc>
and <bbb> and "not their markup".

	<xsl:template match="root">
<xsl:copy>
<xsl:attribute name="dummy">the_root</xsl:attribute>

			<xsl:apply-templates/>
			<xsl:apply-templates select=".//aaa"/>
			<xsl:comment>
			<xsl:apply-templates select="./abc | .//bbb"/>
			</xsl:comment>
</xsl:copy>
	</xsl:template>



Hope I've made myself clear and any ideas in this regard will be highly
appreciated.


Best,

Pankaj Chaturvedi

============================================================================
================


Confidentiality Notice:" This message and any attachment(s)
contained here are information that is confidential, proprietary to
IDS Infotech Ltd. and its customers.
Contents may be privileged or otherwise protected by law. The
information is solely intended for the individual or the entity it
is addressed to. If you are not the intended recipient of this
message, you are not authorized to read, forward, print, retain,
copy or disseminate this message or any part of it. If you have
received this e-mail in error, please notify the sender immediately
by return e-mail and delete it from your computer."

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.