RE: [xsl] Unique node and delimiter concatenation

Subject: RE: [xsl] Unique node and delimiter concatenation
From: "Sreeni Yetchina -X \(syetchin - Pure Solutions at Cisco\)" <syetchin@xxxxxxxxx>
Date: Thu, 29 Mar 2007 14:54:51 -0700

One thing I can tell you is your test condition is not correct.
<xsl:if test="position() &lt; last()-1 and $warn='Y'">
Instead of

<xsl:if test="position() &lt; last()-1 and test=$warn='Y'">

Please note that you don't need to repeat the "test =" clause for a
Boolean condition, just use the correct parenthesis with Boolean AND or
OR conditions with in the same "test" clause.

This change at more then one place in your code is giving the output as
"1 and" since your logic is not correct.
Please check your logic, the last node set of the LINE_ITEM got the
CUST_MSG as "N" that's why the PRODUCT_NUMBER "2" in it is not getting
Good luck,

-----Original Message-----
From: Senthilkumaravelan K [mailto:skumaravelan@xxxxxxxxxxxxxx]
Sent: Thursday, March 29, 2007 2:20 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Unique node and delimiter concatenation

Hi ,
I getting struck with border condition in the below xslt when i am
trying to concatenate with "," "and " while finding unique node based on
the condition.
Can any one suggest me how I could over come this ?

My xml looks like
my XSLT the same
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
<xsl:output method="html" />
<xsl:key name="getUniqueData" match="PRODUCT_NUMBER" use="."/>
<xsl:template match="/"> <xsl:variable name="itemsOfthisProduct"
select="//LINE_ITEM"/> <products> <xsl:for-each
= generate-id(key('getUniqueData',.))]">
<xsl:variable name="warn"
select="following-sibling::*[contains(name(), 'CUST_MSG')]"  /> <xsl:if
test="$warn='Y'"> <xsl:value-of select="."/> </xsl:if> <xsl:if
test="position() &lt; last()-1 and test=$warn='Y'"> <xsl:message>less
than</xsl:message> <xsl:text>, </xsl:text></xsl:if> <xsl:if
test="position()=last()-1 and test=$warn='Y'"><xsl:text>and
</xsl:text></xsl:if> <xsl:if test="position()=last() and

My expected out is
<products>1 and 2.
depends on the CUST_MSG value I need to concatenate "," and respective

Am facing some border condition it is failing to produce the desired
Please help.

Current Thread