[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: "Deepak Rao" <deepaksubs@xxxxxxxxxxx>
Date: Thu, 31 Oct 2002 16:57:55 -0500
|
hey steven thanks for all the help
but i think i confused all this time too
i am going to try again
Input XML Output XML
<X> maps to----> <X1>
<A>A</A> maps to----> <A1>A</A>
<Y> maps to---> <Y1>
if resultant <Y1>
has got elements within it
<B>B</B> maps to----> <B1>B1</B1>
only if data contained
in <B> is "ABC"
<C>C</C> maps to----> <C1>C1</C1>
only if data contained
in <C> is "XYZ"
</Y> </Y1>
</X> </X>
According to the mapping rules for <B> and <C> the output XML should not
contain <B1> and <C1> and thus <Y1> would be empty. But <Y1> should appear
in the output only if <B1> or <C1> is present.
what can I use for that
Thanks,
Deepak
From: "KIENLE, STEVEN C [IT/0200]" <steven.c.kienle@xxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: "'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: RE: Delete XML Node
Date: Thu, 31 Oct 2002 16:14:50 -0500
Replace the for each with the Y[Z] with the following:
<xsl:for-each select="Y[child::*]">
<xsl:copy-of select="." />
</xsl:for-each>
This will fire only for those Y which have children. Then it makes a deep
copy of that node.
If you need this logic to apply you node more than Y, then you may want to
look at multiple templates instead of for-each elements.
-----Original Message-----
From: Deepak Rao [mailto:deepaksubs@xxxxxxxxxxx]
Sent: Thursday, October 31, 2002 4:04 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: Delete XML Node
Whoops, I shot myself in the foot here....
sorry folks I am new to XSL.... and pardon my ignorrance
To clarify things, I want an XSL which would output a <Y> if and only if it
has a sub element in this case a <Z>. In the current example I have only
one
sub element <Z> but there can be more than one sub-element of <Y>.
e.g.
<Y>
<Z></Z>
<D></D>
......
</Y>
I do not want <Y></Y> to appear in the output if all the sub-elements do
not
map.
Thanks,
Deepak
>From: "KIENLE, STEVEN C [IT/0200]" <steven.c.kienle@xxxxxxxxxxxxx>
>Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>To: "'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
>Subject: RE: Delete XML Node
>Date: Thu, 31 Oct 2002 14:27:42 -0500
>
>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
_________________________________________________________________
Internet access plans that fit your lifestyle -- join MSN.
http://resourcecenter.msn.com/access/plans/default.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
_________________________________________________________________
Get faster connections?-- switch to?MSN Internet Access!
http://resourcecenter.msn.com/access/plans/default.asp
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|