Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Xsl pattern help...

From: "Chris Lovett" <someone@------.------>
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
>>
>>
>> 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent