Subject: RE: Template matching preceding-sibling.
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 14 Nov 2007 08:28:59 -0000
|
You're missing that != (like the other comparison operators) returns true if
any item on the left is != to any item on the right. You probably want
not(activity = preceding-sibling::Rec/activity)
but I haven't looked at the problem, it might be that you want
not(activity = preceding-sibling::Rec[1]/activity)
which only looks at the immediately preceding sibling.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Ilya Konanykhin [mailto:ilya.konanykhin.ml@xxxxxxxxx]
> Sent: 14 November 2007 04:01
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: Template matching preceding-sibling.
>
> Hi, list!
> I'm asking for clarification of the topic being on the list
> several days ago (Nov 8). Steve <subsume@xxxxxxxxx> wrote:
>
> > 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?
>
> Charles Knell and Scott Trenda gave advices/made notices,
> thus confirming, that the problem exists. But copying the
> input data and the template given by Steve and running it I
> obtained exactly the result required by him in the first
> topic-forming message, if I understood his request correctly.
> I used MSXML (not sure about version, but don't think it's
> important in this simple
> case) and Saxon 9, for the latter I also tried changing
> template version to 2.0 - the result stood the same. Data follows:
>
> -----------
> input.xml:
> <?xml version="1.0"?>
>
> <xml>
> <Rec>
> <activity>hi</activity>
> </Rec>
> <Rec>
> <activity>hi</activity>
> </Rec>
> </xml>
>
> -----------
> input.xsl:
> <?xml version="1.0"?>
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>
> <xsl:template match="Rec[activity !=
> preceding-sibling::Rec/activity or not(preceding-sibling::Rec)]">
> Ello xslers.
> </xsl:template>
>
> </xsl:stylesheet>
>
> -----------
> output.xml:
> <?xml version="1.0" encoding="UTF-8"?>
>
> Ello xslers.
>
>
> hi
>
> -----------
>
> As it is clearly seen the string "Ello xslers" appears only
> once and not twice as Steve wrote ("hi" comes from the defaul
> copy rules, as I understand it).
>
> Did I missed or misunderstood something very basic? Can
> someone please reveal the trick to me (especially interested
> in Charles' oppinion as he was involved most intensively in
> the discussion).
>
> Many thanks in advance,
> Ilya
| Current Thread |
Ilya Konanykhin - 14 Nov 2007 04:02:06 -0000
- Michael Kay - 14 Nov 2007 08:29:48 -0000 <=
- Wendell Piez - 14 Nov 2007 16:56:31 -0000
|
|