[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Unique node and delimiter concatenation

Subject: Re: Unique node and delimiter concatenation
From: "Senthilkumaravelan K" <skumaravelan@xxxxxxxxxxxxxx>
Date: Thu, 29 Mar 2007 15:23:49 -0700
 Re: Unique node and delimiter concatenation
Hi Sreeni,
I am sure and it is logic issue and how I could check the second
subsquent node value in the current content and introduce comma.
Second value may or may not be there.
How I could select and introuce "," based on the second sibling value.
Let me know is thre any way I could resolve this.
Regards,
Senthil

On 3/29/07, Senthilkumaravelan K <skumaravelan@xxxxxxxxxxxxxx> wrote:
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
<LINE_ITEMS>
<LINE_ITEM>
<PRODUCT_NUMBER>1</PRODUCT_NUMBER>
<CUST_MSG>Y</CUST_MSG>
</LINE_ITEM>
<LINE_ITEM>
<PRODUCT_NUMBER>1</PRODUCT_NUMBER>
<CUST_MSG>Y</CUST_MSG>
</LINE_ITEM>
<LINE_ITEM>
<PRODUCT_NUMBER>1</PRODUCT_NUMBER>
<CUST_MSG>Y</CUST_MSG>
</LINE_ITEM>
<LINE_ITEM>
<PRODUCT_NUMBER>2</PRODUCT_NUMBER>
<CUST_MSG>N</CUST_MSG>
</LINE_ITEM>
</LINE_ITEMS>
and
my XSLT the same
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<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 select="$itemsOfthisProduct/PRODUCT_NUMBER[generate-id()
= 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 test=$warn='Y'"><xsl:text>.</xsl:text>
</xsl:if>
 </xsl:for-each>
</products>
</xsl:template>
</xsl:stylesheet>

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

Am facing some border condition it is failing to produce the desired output.
Please help.
Regards,
Senthil

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.