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/7/2005 12:07:00 AM Well assuming you already did selectNodes("//Item") then for each
IXMLDOMNode that you get back just do the following:
Dim name as string
name = node.parentNode.nodeName
Then see if this string is equal to "Available" or "NotAvailable".
"K. Wilder" <KWilder@d...> wrote in message
news:5C021AE1-1399-42C6-BC0E-2330711AD300@m......
> 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 | |||
|
