Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to increment or decrement a value in xsl,how to decrement position( )

User609824-OracleDec 17 2012 — edited Dec 19 2012
Hi,

I am new to xsl coding and I am facing an issue with position() function in xsl.I have a "sequence number" that is being shown in the output xml and the value is derived from position inside a for each loop.I am suppressing the complete parent tag when the value of Amount is 0.00 and hence the sequence number is jumping when the amounts are 0.00.The amount is derived from a particular group and hence cannot be checked for zero outside for.I am not able to take a variable and increment the value in the for each loop as well.Can anyone please help me resolve this issue.I am attaching my xsl and the xml to be processed and also the output xml I am getting currently.In the output the <ns2:IntraClient SequenceNumber="1">is missing as the value of <ns2:Amount> is 0.00.Also the value of ClientsNbr="97" which is derrived from position() last() should be 96 instead excluding the 0 value.

Thank You,
Divya.

<?xml version="1.0" encoding="UTF-8" ?>
<!-- dbdrv: exec java oracle/apps/xdo/oa/util XDOLoader.class java &phase=dat checkfile:~PROD:patch/115/publisher/templates:CLEF343ESLBE.xsl UPLOAD -DB_USERNAME &un_apps -DB_PASSWORD &pw_apps -JDBC_CONNECTION &jdbc_db_addr -LOB_TYPE TEMPLATE -APPS_SHORT_NAME ~PROD -LOB_CODE CLEF343ESLBE -LANGUAGE en -TERRITORY US -XDO_FILE_TYPE XSL-XML -FILE_NAME &fullpath:~PROD:patch/115/publisher/templates:CLEF343ESLBE.xsl -->
<!-- $Header: CLEF343ESLBE.xsl 120.0.12000000.31 2012/12/10 07:19:01 dmuthyal noship $ -->
<!--
+=================================================================================================+
| Copyright (c) 2006 Oracle Corporation, Redwood Shores, CA, USA |
| All rights reserved. |
+=================================================================================================+
-->
<!-- HISTORY
=============================================================================================
DEVELOPER DATE VER PURPOSE
=============================================================================================
Sapthagiri 03-Jan-2011 1.0 CLE: Sales Listing XML BE
The XSL was re-written as per the legal requirements of 2012
, as per ER bug # 13731823
Divya Muthyala 07-Sep-2011 1.1 Made changes as per bug #13731823 to take a value of 0.00 when the tag
C_FUNCTIONAL_TOTAL is null.
Divya Muthyala 11-Sep-2011 1.1 Made changes as per bug #13731823 to take the first two characteers from tag C_VAT_TAX_REG_NUM
instead of hardcoded value IT for Issued by attribute.
Divya Muthyala 12-Sep-2011 1.2 Made changes as per bug #13731823 to take the c_COUNTRY_CODE1
for Issued by attribute.
Divya Muthyala 12-Sep-2011 1.3 Made changes as per bug #14652250 to correct
Amount.
Divya Muthyala 12-Sep-2012 1.4 Made changes as per bug #14665738 to bring XSL decimal format to a complete line.
Divya Muthyala 12-Sep-2012 1.5 Made changes as per bug #14665738 to correct amount and amount sum values to remove multiplication with 100.
Divya Muthyala 12-Sep-2012 1.6 Made changes as per bug #14665738 to correct amount and amount sum format to remove grouping separator and retain '.' as decimal separator.
Divya Muthyala 30-Nov-2012 1.7 Made changes as per bug #15843866 not to show the information where ever amounts are zero.
Divya Muthyala 05-Dec-2012 1.8 Made changes as per bug #14805003 not to show EL before registration number and replace or GR with EL for issued by.
=============================================================================================
END HISTORY -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:key name="group" match="G_REP_TRX_DETAIL_INFO" use="concat(C_VAT_TAX_REG_NUM,C_CUST_NAME,C_TAX_REPORTING_CODE)"/>
<xsl:template name="replaceCharsInString">
<xsl:param name="stringIn"/>
<xsl:param name="charsIn"/>
<xsl:param name="charsOut"/>
<xsl:choose>
<xsl:when test="contains($stringIn,$charsIn)">
<xsl:value-of select="concat(substring-before($stringIn,$charsIn),$charsOut)"/>
<xsl:call-template name="replaceCharsInString">
<xsl:with-param name="stringIn" select="substring-after($stringIn,$charsIn)"/>
<xsl:with-param name="charsIn" select="$charsIn"/>
<xsl:with-param name="charsOut" select="$charsOut"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$stringIn"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Root template -->
<xsl:template match="/">
<xsl:variable name="pvatnum">
<xsl:value-of select="substring(/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/CP_FIRST_PARTY_TAX_REG_NUM,3,10)"/>
</xsl:variable>
<ns2:IntraConsignment xmlns="http://www.minfin.fgov.be/InputCommon" xmlns:ns2="http://www.minfin.fgov.be/IntraConsignment">
<xsl:attribute name="IntraListingsNbr">1</xsl:attribute><xsl:text>&#xD;</xsl:text>
<xsl:choose><xsl:when test="not(C_FUNCTIONAL_TOTAL='')">
<xsl:choose><xsl:when test="not(format-number((sum(/ZXXEUSL/LIST_G_REP_TRX_DETAIL_INFO/G_REP_TRX_DETAIL_INFO/C_FUNCTIONAL_TOTAL)) , &quot;0.00&quot;)='0.00')">
<ns2:IntraListing>
<xsl:attribute name="AmountSum"><xsl:choose><xsl:when test="not(C_FUNCTIONAL_TOTAL='')"><xsl:value-of select="format-number((sum(/ZXXEUSL/LIST_G_REP_TRX_DETAIL_INFO/G_REP_TRX_DETAIL_INFO/C_FUNCTIONAL_TOTAL)) , &quot;0.00&quot;)"/></xsl:when>
</xsl:choose></xsl:attribute>
<xsl:attribute name="DeclarantReference"></xsl:attribute>
<xsl:attribute name="ClientsNbr"><xsl:apply-templates select=".//LIST_G_REP_TRX_DETAIL_INFO"/> </xsl:attribute>
<xsl:attribute name="SequenceNumber">1</xsl:attribute> <xsl:text>&#xD;</xsl:text>
<xsl:apply-templates select=".//G_REP_PARAMETER_INFO"/>
<xsl:apply-templates select=".//G_REP_PARAMETER_INFO" mode="Period"/>
<xsl:apply-templates select=".//LIST_G_REP_TRX_DETAIL_INFO" mode="t1mode"/>
<xsl:apply-templates select=".//G_REP_PARAMETER_INFO" mode="Comm"/>
</ns2:IntraListing><xsl:text>&#xD;</xsl:text></xsl:when></xsl:choose></xsl:when></xsl:choose>
</ns2:IntraConsignment>
</xsl:template>
<xsl:template match="G_REP_PARAMETER_INFO" xmlns:ns2="http://www.minfin.fgov.be/IntraConsignment">
<ns2:Declarant><xsl:text>&#xD;</xsl:text>
<VATNumber><xsl:value-of select="substring(CP_FIRST_PARTY_TAX_REG_NUM,1,14)" /></VATNumber><xsl:text>&#xD;</xsl:text>
<Name><xsl:value-of select="substring(CP_REP_CONTEXT_ENTITY_NAME,1,200)"/></Name><xsl:text>&#xD;</xsl:text>
<Street><xsl:value-of select="substring(concat(CP_ADDRESS_LINE_1,' ',CP_ADDRESS_LINE_2),1,200)"/></Street><xsl:text>&#xD;</xsl:text>
<PostCode><xsl:value-of select="substring((/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/CP_POSTAL_CODE),1,200)"/></PostCode><xsl:text>&#xD;</xsl:text>
<City><xsl:value-of select="substring((/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/CP_TOWN_OR_CITY),1,200)"/></City><xsl:text>&#xD;</xsl:text>
<CountryCode>BE</CountryCode><xsl:text>&#xD;</xsl:text>
<EmailAddress><xsl:value-of select="P_CUSTOM_CHAR4" /></EmailAddress><xsl:text>&#xD;</xsl:text>
<Phone><xsl:value-of select="P_CUSTOM_CHAR5" /></Phone><xsl:text>&#xD;</xsl:text>
</ns2:Declarant><xsl:text>&#xD;</xsl:text>
</xsl:template>
<xsl:template match="G_REP_PARAMETER_INFO" mode="Period" xmlns:ns2="http://www.minfin.fgov.be/IntraConsignment">
<ns2:Period><xsl:text>&#xD;</xsl:text>
<ns2:Month><xsl:value-of select="P_CUSTOM_CHAR7" /></ns2:Month><xsl:text>&#xD;</xsl:text>
<ns2:Year><xsl:value-of select="P_CUSTOM_CHAR3" /></ns2:Year><xsl:text>&#xD;</xsl:text>
</ns2:Period><xsl:text>&#xD;</xsl:text>
</xsl:template>
<xsl:template name="Temp1" match="LIST_G_REP_TRX_DETAIL_INFO" mode="t1mode" xmlns:ns2="http://www.minfin.fgov.be/IntraConsignment">
<xsl:for-each select="G_REP_TRX_DETAIL_INFO[generate-id()=generate-id(key('group', concat(C_VAT_TAX_REG_NUM,C_CUST_NAME,C_TAX_REPORTING_CODE))[1])]">
<xsl:choose><xsl:when test="not(C_FUNCTIONAL_TOTAL='')">
<xsl:choose><xsl:when test="not(format-number((sum(key('group', concat(C_VAT_TAX_REG_NUM,C_CUST_NAME,C_TAX_REPORTING_CODE))/C_FUNCTIONAL_TOTAL)) , &quot;0.00&quot;)='0.00')
and not(format-number((sum(key('group', concat(C_VAT_TAX_REG_NUM,C_CUST_NAME,C_TAX_REPORTING_CODE))/C_FUNCTIONAL_TOTAL)) , &quot;0.00&quot;)='-0.00')">
<ns2:IntraClient>
<xsl:attribute name="SequenceNumber"><xsl:variable name="iCount" select="position()" /><xsl:value-of select="$iCount" /></xsl:attribute> <xsl:text></xsl:text>
<ns2:CompanyVATNumber>
<xsl:attribute name="issuedBy">
<xsl:call-template name="replaceCharsInString">
<xsl:with-param name="stringIn" select="string(C_COUNTRY_CODE1)"/>
<xsl:with-param name="charsIn" select="'GR'"/>
<xsl:with-param name="charsOut" select="'EL'"/>
</xsl:call-template>
</xsl:attribute><xsl:text>&#xD;</xsl:text>
<xsl:call-template name="replaceCharsInString">
<xsl:with-param name="stringIn" select="string(C_VAT_TAX_REG_NUM)"/>
<xsl:with-param name="charsIn" select="'EL'"/>
<xsl:with-param name="charsOut" select="''"/>
</xsl:call-template>
</ns2:CompanyVATNumber><xsl:text>&#xD;</xsl:text>
<ns2:Code><xsl:value-of select="C_TAX_REPORTING_CODE" /></ns2:Code><xsl:text>&#xD;</xsl:text>
<ns2:Amount><xsl:choose><xsl:when test="not(C_FUNCTIONAL_TOTAL='')"><xsl:value-of select="format-number((sum(key('group', concat(C_VAT_TAX_REG_NUM,C_CUST_NAME,C_TAX_REPORTING_CODE))/C_FUNCTIONAL_TOTAL)) , &quot;0.00&quot;)" /></xsl:when>
</xsl:choose></ns2:Amount><xsl:text>&#xD;</xsl:text>
</ns2:IntraClient><xsl:text>&#xD;</xsl:text></xsl:when>
<xsl:otherwise>
<xsl:variable name="iCount" select="position()-1"/>
</xsl:otherwise></xsl:choose></xsl:when></xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template match="G_REP_PARAMETER_INFO" mode="Comm" xmlns:ns2="http://www.minfin.fgov.be/IntraConsignment">
<ns2:Comment><xsl:value-of select="P_CUSTOM_CHAR6" /></ns2:Comment><xsl:text>&#xD;</xsl:text>
</xsl:template>
<xsl:template name="Temp2" match="LIST_G_REP_TRX_DETAIL_INFO">
<xsl:for-each select="G_REP_TRX_DETAIL_INFO[generate-id()=generate-id(key('group', concat(C_VAT_TAX_REG_NUM,C_CUST_NAME,C_TAX_REPORTING_CODE))[1])]">
<xsl:choose><xsl:when test="not(C_FUNCTIONAL_TOTAL='')">
<xsl:choose><xsl:when test="not(format-number((sum(key('group', concat(C_VAT_TAX_REG_NUM,C_CUST_NAME,C_TAX_REPORTING_CODE))/C_FUNCTIONAL_TOTAL)) , &quot;0.00&quot;)='0.00')
and not(format-number((sum(key('group', concat(C_VAT_TAX_REG_NUM,C_CUST_NAME,C_TAX_REPORTING_CODE))/C_FUNCTIONAL_TOTAL)) , &quot;0.00&quot;)='-0.00')">
<xsl:variable name="jCount" select="position()" />
<xsl:if test="position()=last()">
<xsl:value-of select="$jCount" />
</xsl:if>
</xsl:when></xsl:choose>
</xsl:when></xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 16 2013
Added on Dec 17 2012
6 comments
950 views