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

Re: returning nodes which have a specific child

Subject: Re: returning nodes which have a specific child
From: jim mcgovern <jim.mcgovern2@xxxxxxxxxxxxxx>
Date: Thu, 2 Jul 2009 09:21:41 +0100
Re:  returning nodes which have a specific child
Hi Michael

Thanks very much for that!  Worked a treat.

I'm relatively new to xsl and to be honest a lot of it seems like a
black art.  Can you briefly describe what your solution does?  I feel
daft for asking seeing as it's 13 lines long but I'd have never come
up with that.

Many thanks


On Wed, Jul 1, 2009 at 9:20 AM, Michael Ludwig<mlu@xxxxxxxxxxxxx> wrote:
> jim mcgovern schrieb:
>> What I need to do is return a set of nodes that contain a certain
>> child node.  In the case below I need to return all the nodes that
>> contain a child node which have a name of "CONTENT".
>> And what I need to end up with is:-
>> <folder name="dir2" id="x2">
>>        <folder name="dir5" id="x5">
>>                <folder name="dir7" id="x7">
>>                </folder>
>>        </folder>
>> </folder>
> Hi Jim,
> the following seems to work. Should be rather self-explanatory; if not,
> feel free to come back with any questions you might have.
> <xsl:stylesheet version="1.0"
>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>  <xsl:template match="@*|node()"><!-- identity template -->
>    <xsl:copy>
>      <xsl:apply-templates select="@*|node()"/>
>    </xsl:copy>
>  </xsl:template>
>  <xsl:template match="*" priority="-0.4" ><!-- skip unwanted -->
>    <xsl:apply-templates select="*"/>
>  </xsl:template>
>  <xsl:template match="*[*[@name='CONTENT']]" ><!-- keep wanted -->
>    <xsl:copy>
>      <xsl:apply-templates select="@*|node()"/>
>    </xsl:copy>
>  </xsl:template>
> </xsl:stylesheet>
> Michael Ludwig

Current Thread


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.
First Name
Last Name
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.