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

Re: Select Parent when child exists

Subject: Re: Select Parent when child exists
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Tue, 27 Nov 2007 10:38:03 +0000
Re:  Select Parent when child exists
On 27/11/2007, Tim Gaunt <info@xxxxxxxxxxxxxxxxxxx> wrote:
> Hi,
>
> I'm trying to select all the parents that have a child node matching a
> certain value. It's basically transforming a blog RSS feed and I only want
> to select those posts that have a specific tag.
>
> The feed looks like this:
> <feed>
>         <post>
>                 <title>Title of the post 1</title>
>                 <tags>
>                         <tag>example</tag>
>                 </tags>
>         </post>
>         <post>
>                 <title>Title of the post 2</title>
>                 <tags>
>                         <tag>example2</tag>
>                 </tags>
>         </post>
>         <post>
>                 <title>Title of the post 3</title>
>                 <tags>
>                         <tag>example</tag>
>                         <tag>example3</tag>
>                 </tags>
>         </post>
> </feed>
>
> In this example I want posts 1 and 3.
>
> I've had a Google around but I've not found any definitive answer. I was
> thinking of an if statement but I would like to look the latest x posts and
> I'm not sure how I can do that using an if statement as postion() is
> incremental regardless of the quantifier.

If you mean, "how do you select all <post> elements that contain a
child <tag> element with the value 'example' " then then its:

select="post[tags/tag = 'example']"


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

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.