RE: Re: [xsl] Template matching preceding-sibling.

Subject: RE: Re: [xsl] Template matching preceding-sibling.
From: cknell@xxxxxxxxxx
Date: Thu, 08 Nov 2007 13:26:24 -0500
No need to apologize. Yes, the first <Rec> is the preceding-sibling of the second <Rec>, but that's not what your XPath expression tests. Please re-read my response. Your expression tests to find a <Rec> element whose child <activity> doesn't have a preceding-sibling <Rec>. Since neither of the <activity> elements has any siblings of any kind, your expression matches them both.

Perhaps you want this one, instead:

Rec[not(preceding-sibling()=Rec)]

I'm not at my regular computer, so I can't test the expression, but I can eyeball yours and tell that it isn't what you think it is.
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Steve <subsume@xxxxxxxxx>
Sent:     Thu, 8 Nov 2007 13:16:42 -0500
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Re: [xsl] Template matching preceding-sibling.

I'm sorry, but isn't the first <Rec> in my XML the preceding-sibling
of the second <Rec> ?

-Steve

On Nov 8, 2007 1:13 PM,  <cknell@xxxxxxxxxx> wrote:
> Your template matches both <Rec> elements, so you get two instances of "Ello xslers." in your output.
>
> Your template matches and <Rec> element with an <activity> child element that doesn't have preceding-sibling <Rec>. Since both <Rec> elements have <activity> child elements, and since none of the <activity> elements has a preceding-sibling of ANY kind, you are matching both <Rec>s.
> --
> Charles Knell
> cknell@xxxxxxxxxx - email
>
>
>
>
> -----Original Message-----
> From:     Steve <subsume@xxxxxxxxx>
> Sent:     Thu, 8 Nov 2007 12:59:01 -0500
> To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  [xsl] Template matching preceding-sibling.
>
> I'm missing something fundamental, what is it?
>
> <xsl:template match="Rec[activity != preceding-sibling::Rec/activity
> or not(preceding-sibling::Rec)]">
>   Ello xslers.
> </xsl:template>
>
> <xml>
>    <Rec>
>      <activity>hi</activity>
>    </Rec>
>    <Rec>
>       <activity>hi</activity>
>    </Rec>
> </xml>
>
> ----
>
> Above should only print anything once, but I'm getting it each time.
> What am I not getting?
>
> -Steve

Current Thread