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(_dot_)konanykhin(_dot_)ml(_at_)gmail(_dot_)com]
Sent: 14 November 2007 04:01
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] 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(_at_)gmail(_dot_)com> 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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--