[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Re: xsl-list Digest 22 Jan 2005 06:10:00 -0000 Issue 305


Subject: [xsl] Re: xsl-list Digest 22 Jan 2005 06:10:00 -0000 Issue 305
From: Lars Huttar <lars@xxxxxxxxxx>
Date: Sat, 22 Jan 2005 07:44:08 -0600

jvalentin wrote:

i am using this duplicate removing xsl script:
<xsl:template match = "/">
 <!-- predicate to avoid node ABC... group repetition -->
 <xsl:apply-templates select="/xml/el[not(node=following::node)]">
   <xsl:sort select="node" />
 </xsl:apply-templates>
</xsl:template>

<xsl:template match="el">
 <xsl:value-of select="node">-<xsl:call-template
name="XXX"><xsl:with-param name="node" ><xsl:value-of select="node"
/></xsl:with-param></xsl:call-template>
</xsl:template>

<xsl:template name="XXX">
 <!--
 when using:
 <xsl:for-each
select="/xml/el[node=$node]/rel/el/node[not(text()=following::text())]">
 the first predicate is not accounted for, and all XYZ are visible and i
get this:
       A-Y
       B-X
       C-Z

 and if i use this axe:
 <xsl:for-each
select="/xml/el[node=$node]/rel/el/node[not(text()=following-sibling::text())]">
 i get again all with duplicates:
       A-XXY
       B-XZZ
       C-Z

 when i use no last predicate:
 <xsl:for-each select="/xml/el[node=$node]/rel/el/node">
 intra-class ABC duplicates remain:
       A-XXY
       B-XZZ
       C-Z
 -->
   <xsl:value-of select="text()">
 </xsl:for-each>
</xsl:template>

any idea on what's the reason for this behaviour of predicate [node=$node]
(i tried keys with the same result)

thanks


The predicate is working, i.e. when you call template "XXX" with a value of 'A' for parameter "node", the template only outputs the names of nodes related to the 'A' element.
What the predicate doesn't do is restrict the range of the following:: and following-sibling:: axes.
So when you are looking at node A-X and you ask if there is a following text node whose value is 'X', the answer is yes because there is one under B.


Lars


Current Thread
Keywords
xsl