Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Xsl pattern help... >Thread Next - Re: Xsl pattern help... Re: Xsl pattern help...To: NULL Date: 7/5/2005 11:23:00 AM Chris, Thanks for the information. I apologize for not being completely clear, I failed to say that I needed this as XPath pattern to be used in VB.Net. Such as, selectSingleNode([pattern goes here]) I didn't mean for it to be used with an XSL stylesheet. My bad. It doesn't seem that name() or other node queries work in XPath expressions. Is there a way of doing what I want in an XPath expression? Thanks again, King Wilder "Chris Lovett" wrote: > 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 | |||
|
