Re: [xsl] Template matching preceding-sibling.

Subject: Re: [xsl] Template matching preceding-sibling.
From: "Ilya Konanykhin" <ilya.konanykhin.ml@xxxxxxxxx>
Date: Wed, 14 Nov 2007 10:00:53 +0600
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