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

Re: conditional increment under XSL for-each loop

Subject: Re: conditional increment under XSL for-each loop
From: "anil an.kumar" <anil.an.kumar@xxxxxxxxxx>
Date: Wed, 10 Feb 2010 16:38:38 +0530
Re:  conditional increment under XSL for-each loop
Hi Martin,

Thanks for your precious time and response.

iam using  XSL  version 1,
and  i got the required out put by applying the below logic..

<xsl:for-each select="G_REP_TRX_DETAIL_INFO/C_TAX_REPORTING_NAME">
 <mezo eazon="{format-number((position()+1) idiv 2,'000')}X{((position()+1) mod 2) + 1}A">
   <xsl:value-of select="."/>
 </mezo>
</xsl:for-each>



Thanks a lot
Anil




On 2/9/2010 6:53 PM, Martin Honnen wrote:
anil an.kumar wrote:

I have a requirment which should show the xml o/p like below

<instance>
<mezo eazon="001X1A">abc</mezo>
<mezo eazon="001X2A">def</mezo>
<mezo eazon="002X1A">xyz</mezo>
<mezo eazon="002X2A">abc</mezo>
<mezo eazon="003X1A">def</mezo>
<mezo eazon="003X2A">xyz</mezo>
<mezo eazon="004X1A">aaa</mezo>
<mezo eazon="004X2A">bbb</mezo>
<mezo eazon="005X1A">ccc</mezo>
<mezo eazon="005X2A">xyz</mezo>
</instance>


The tag "001X1A" should frame in such a way that,
POINT1 : The number appearing before 'A' should reset after every two records
POINT2 : The number appearing before 'X' should be same and need to increment by 1 for every two records.
like 001,001 then 002,002 then 003....

Here is an XSLT 2.0 stylesheet that produces above output:


<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="2.0">

<xsl:output indent="yes"/>

<xsl:template match="/">
<instance>
<xsl:for-each-group select="//C_TAX_REPORTING_NAME" group-by="(position() - 1) idiv 2">
<mezo eazon="{format-number(current-grouping-key() + 1, '000')}X1A">
<xsl:value-of select="current-group()[1]"/>
</mezo>
<mezo eazon="{format-number(current-grouping-key() + 1, '000')}X2A">
<xsl:value-of select="current-group()[2]"/>
</mezo>
</xsl:for-each-group>
</instance>
</xsl:template>


</xsl:stylesheet>

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.