Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Xsl pattern help... >Thread Next - Re: Xsl pattern help... Re: Xsl pattern help...To: NULL Date: 7/4/2005 11:49:00 PM Well, once you've found the matching <Item> element, the XPath query ".." will select the parent element which is <Available> or <NotAvailable> so the relative query "name(..)" will return the name of this parent. So the following XSL stylesheet: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > <xsl:template match="/"> <xsl:apply-templates select="//Item"/> </xsl:template> <xsl:template match="Item"> <xsl:value-of select="."/>=<xsl:value-of select="name(..)"/><xsl:text> </xsl:text> </xsl:template> </xsl:stylesheet> Produces the following output: Dog=Available Cat=Available Horse=Available Bird=NotAvailable Lizard=NotAvailable Fish=NotAvailable "K. Wilder" <KWilder@d...> wrote in message news:B4835EE1-6643-45FC-890D-494C268C39E8@m...... >I have this xml... > > <Root> > <Body> > <Available> > <Item>Dog</Item> > <Item>Cat</Item> > <Item>Horse</Item> > </Available> > <NotAvailable> > <Item>Bird</Item> > <Item>Lizard</Item> > <Item>Fish</Item> > </NotAvailable> > </Body> > </Root> > > I want to find which node, (Available or NotAvailable) any particular Item > is in. Example: If I'm looking for "Fish" I want it to return > NotAvailable. > > I can't quite figure this one out. > > Any help is appreciated. > > Thanks, > > King Wilder | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
