Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - [xsl] returning nodes which have a specific child >Thread Next - Re: [xsl] returning nodes which have a specific child Re: [xsl] returning nodes which have a specific childTo: xsl-list@-----.------------.--- Date: 7/1/2009 8:21:00 AM 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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@l...>
--~--
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
