Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2010, 09:47 AM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default summing the already grouped records

Hi ,

iam facing some sum in grouped records ..

i have provided my Question below...


iam geting AA value from this
<xsl:for-each-group select="G_REP_TRX_DETAIL_INFO[C_TAX_REPORTING_NAME = '01']" group-by="concat(C_BILLING_TP_TAX_REG_NUM,C_TAX_REPORTIN G_NAME)">
<AA><xsl:value-of select="sum(current-group()/C_FUNCTIONAL_TOTAL)"/></AA><xsl:text>&#xD;</xsl:text>
</xsl:for-each-group>


iam able to display the below o/p
<AA>200</AA>
<AA>150</AA>
<AA>300</AA>
<AA>50</AA>


But my out put should also include ,
BB with sum of every 3 AA records ...


<AA>200</AA>
<AA>150</AA>
<AA>300</AA>
<BB>650</BB> -- total of above 3 AA records
<AA>50</AA>

How can i add these AA values,
as these AA- tags dosen't exists in my source XML (coz these are formed only in my XSL with the for each group)

Kindly give your valuable suggestions

iam providing my xsl and xml files


xsl
Code:
 
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output  method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:apply-templates select=".//LIST_G_REP_TRX_DETAIL_INFO"/>
</xsl:template>

<xsl:template match="LIST_G_REP_TRX_DETAIL_INFO">
<xsl:for-each-group select="G_REP_TRX_DETAIL_INFO[C_TAX_REPORTING_NAME = '01']" group-by="concat(C_BILLING_TP_TAX_REG_NUM,C_TAX_REPORTING_NAME)">
<AA><xsl:value-of select="sum(current-group()/C_FUNCTIONAL_TOTAL)"/></AA><xsl:text>&#xD;</xsl:text>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet >
Code:
<ZXXEUSL>
 <LIST_G_REP_PARAMETER_INFO>
   <G_REP_PARAMETER_INFO>
     <CP_ESL_ROUND_RULE_CODE>NO</CP_ESL_ROUND_RULE_CODE>
   </G_REP_PARAMETER_INFO>
 </LIST_G_REP_PARAMETER_INFO>
 <LIST_G_REP_TRX_DETAIL_INFO>
   <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>abc</C_BILLING_TP_TAX_REG_NUM>
     <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
     <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
   <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>def</C_BILLING_TP_TAX_REG_NUM>
     <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
	 <C_FUNCTIONAL_TOTAL>50</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
    <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>xyz</C_BILLING_TP_TAX_REG_NUM>
	  <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
	  <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
    <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>abc</C_BILLING_TP_TAX_REG_NUM>
	  <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
	  <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
    <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>def</C_BILLING_TP_TAX_REG_NUM>
	  <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
	  <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
    <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>xyz</C_BILLING_TP_TAX_REG_NUM>
	  <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
	  <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
    <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>abc</C_BILLING_TP_TAX_REG_NUM>
	  <C_TAX_REPORTING_NAME>02</C_TAX_REPORTING_NAME>
	  <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
     <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>bbb</C_BILLING_TP_TAX_REG_NUM>
	  <C_TAX_REPORTING_NAME>02</C_TAX_REPORTING_NAME>
	  <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
      <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>xyz</C_BILLING_TP_TAX_REG_NUM>
	  <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
	  <C_FUNCTIONAL_TOTAL>50</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
      <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>xyz</C_BILLING_TP_TAX_REG_NUM>
	  <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
	  <C_FUNCTIONAL_TOTAL>50</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
         <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>xyz</C_BILLING_TP_TAX_REG_NUM>
	  <C_TAX_REPORTING_NAME>02</C_TAX_REPORTING_NAME>
	  <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
            <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>ddd</C_BILLING_TP_TAX_REG_NUM>
	  <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
	  <C_FUNCTIONAL_TOTAL>50</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
</LIST_G_REP_TRX_DETAIL_INFO>
 <CS_CURRENCY_CODE>GBP</CS_CURRENCY_CODE>
</ZXXEUSL>
Thanks
Anil
 
Old March 11th, 2010, 09:58 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Well with XSLT 2.0 you can easily store a temporary result in a variable and then process it further:
Code:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

<xsl:output  method="xml" indent="yes" omit-xml-declaration="yes"/>

<xsl:template match="/">
  <xsl:apply-templates select=".//LIST_G_REP_TRX_DETAIL_INFO"/>
</xsl:template>

<xsl:template match="LIST_G_REP_TRX_DETAIL_INFO">
  <xsl:variable name="t1" as="element(AA)*">
    <xsl:for-each-group select="G_REP_TRX_DETAIL_INFO[C_TAX_REPORTING_NAME = '01']" group-by="concat(C_BILLING_TP_TAX_REG_NUM,C_TAX_REPORTING_NAME)">
      <AA><xsl:value-of select="sum(current-group()/C_FUNCTIONAL_TOTAL)"/></AA>
    </xsl:for-each-group>
  </xsl:variable>
  <xsl:for-each-group select="$t1" group-by="(position() - 1) idiv 3">
    <xsl:copy-of select="current-group()"/>
    <BB><xsl:value-of select="sum(current-group())"/></BB>
  </xsl:for-each-group>
</xsl:template>

</xsl:stylesheet>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old March 11th, 2010, 11:06 AM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default

Hi,

unfortunatly iam getting like below

<AA>200</AA>
<AA>150</AA>
<AA>300</AA>
<AA>50</AA>
<BB>2.001503005E10</BB>


But my expected out put is ..

<AA>200</AA>
<AA>150</AA>
<AA>300</AA>
<BB>650</BB>
<AA>50</AA>
<BB>50</BB>

Thanks
Anil
 
Old March 11th, 2010, 12:20 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

You will need to post minimal but complete documents allowing us to reproduce the problem. Also state which XSLT processor you use.
When I have the XML input
Code:
<ZXXEUSL>
 <LIST_G_REP_PARAMETER_INFO>
   <G_REP_PARAMETER_INFO>
     <CP_ESL_ROUND_RULE_CODE>NO</CP_ESL_ROUND_RULE_CODE>
   </G_REP_PARAMETER_INFO>
 </LIST_G_REP_PARAMETER_INFO>
 <LIST_G_REP_TRX_DETAIL_INFO>
   <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>abc</C_BILLING_TP_TAX_REG_NUM>
     <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
     <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
   <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>def</C_BILLING_TP_TAX_REG_NUM>
     <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
     <C_FUNCTIONAL_TOTAL>50</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
    <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>xyz</C_BILLING_TP_TAX_REG_NUM>
      <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
      <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
    <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>abc</C_BILLING_TP_TAX_REG_NUM>
      <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
      <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
    <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>def</C_BILLING_TP_TAX_REG_NUM>
      <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
      <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
    <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>xyz</C_BILLING_TP_TAX_REG_NUM>
      <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
      <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
    <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>abc</C_BILLING_TP_TAX_REG_NUM>
      <C_TAX_REPORTING_NAME>02</C_TAX_REPORTING_NAME>
      <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
     <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>bbb</C_BILLING_TP_TAX_REG_NUM>
      <C_TAX_REPORTING_NAME>02</C_TAX_REPORTING_NAME>
      <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
      <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>xyz</C_BILLING_TP_TAX_REG_NUM>
      <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
      <C_FUNCTIONAL_TOTAL>50</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
      <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>xyz</C_BILLING_TP_TAX_REG_NUM>
      <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
      <C_FUNCTIONAL_TOTAL>50</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
         <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>xyz</C_BILLING_TP_TAX_REG_NUM>
      <C_TAX_REPORTING_NAME>02</C_TAX_REPORTING_NAME>
      <C_FUNCTIONAL_TOTAL>100</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
            <G_REP_TRX_DETAIL_INFO>
     <C_BILLING_TP_TAX_REG_NUM>ddd</C_BILLING_TP_TAX_REG_NUM>
      <C_TAX_REPORTING_NAME>01</C_TAX_REPORTING_NAME>
      <C_FUNCTIONAL_TOTAL>50</C_FUNCTIONAL_TOTAL>
   </G_REP_TRX_DETAIL_INFO>
</LIST_G_REP_TRX_DETAIL_INFO>
 <CS_CURRENCY_CODE>GBP</CS_CURRENCY_CODE>
</ZXXEUSL>
which is the one you posted and use the following stylesheet
Code:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

<xsl:output  method="xml" indent="yes" omit-xml-declaration="yes"/>

<xsl:template match="/">
  <xsl:apply-templates select=".//LIST_G_REP_TRX_DETAIL_INFO"/>
</xsl:template>

<xsl:template match="LIST_G_REP_TRX_DETAIL_INFO">
  <xsl:variable name="t1" as="element(AA)*">
    <xsl:for-each-group select="G_REP_TRX_DETAIL_INFO[C_TAX_REPORTING_NAME = '01']" group-by="concat(C_BILLING_TP_TAX_REG_NUM,C_TAX_REPORTING_NAME)">
      <AA><xsl:value-of select="sum(current-group()/C_FUNCTIONAL_TOTAL)"/></AA>
    </xsl:for-each-group>
  </xsl:variable>
  <xsl:for-each-group select="$t1" group-by="(position() - 1) idiv 3">
    <xsl:copy-of select="current-group()"/>
    <BB><xsl:value-of select="sum(current-group())"/></BB>
  </xsl:for-each-group>
</xsl:template>

</xsl:stylesheet>
then both Saxon 9.2 and AltvovaXML tools 2010 R2 output
Code:
<AA>200</AA>
<AA>150</AA>
<AA>300</AA>
<BB>650</BB>
<AA>50</AA>
<BB>50</BB>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old March 12th, 2010, 03:43 AM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default

Hi,

iam using Jdeveloper 10.1.3.3.0

may i know how to get the XSLT processor and its version?


Thanks
Anil
 
Old March 12th, 2010, 08:24 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

You can run the stylesheet http://www.mulberrytech.com/xsl/xsl-...or-version.xsl against any input document to get a HTML document with information about the XSLT processor you use.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old March 12th, 2010, 09:12 AM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default

Hi,


by clicking on this link it is giving below details,
but i think these are my IE browser XSLT details


XSL version: 1
Vendor: Microsoft
Vendor URL: http://www.microsoft.com


BUT iam executing the xsl file in Jdevoper
and iam unable to get the XST processor of my Jdev.

Shall i need to place this link some where in my xsl and execute the file in jdev?
Kindly advice

Thanks
Anil
 
Old March 12th, 2010, 09:19 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

It is a link to a stylesheet. Run that stylesheet the same way you run your other stylesheets with your tool (Jdeveloper). You might need to choose right click -> save link in your browser to store the stylesheet I linked to on your file system first.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old March 12th, 2010, 09:39 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Just add the below template to your stylesheet and check the version:
Code:
<xsl:template match="/">
<p>
      <xsl:text>Vendor: </xsl:text>
      <xsl:value-of select="system-property('xsl:vendor')"/>
    </p>
 <p>
      <xsl:text>Vendor URL: </xsl:text>
      <xsl:value-of select="system-property('xsl:vendor-url')"/>
    </p>
</xsl:template>
__________________
Rummy
 
Old March 12th, 2010, 10:17 AM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default

Hi,


Thanks for patience,

i save the source of link under loop.xsl and ran the xsl file
but It has given error

saved XSL file taken from link ( http://www.mulberrytech.com/xsl/xsl-...or-version.xsl )
<?xml version="1.0"?>
<?xml-stylesheet href="processor-version.xsl" type="text/xsl"?>
<html xsl:version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XSLT Processor Version</title>
</head>
<body>

<p>
<xsl:text>XSL version: </xsl:text>
<xsl:choose>
<xsl:when test="system-property('xsl:vendor') = 'Opera'">1.0</xsl:when>
<xsl:otherwise>
<xsl:value-of select="system-property('xsl:version')"/>
</xsl:otherwise>
</xsl:choose>
</p>
......
......
</html>

ERROR:
The web target loop1.xsl cannot be started because it is not in the project HTML root directory.
The target loop1.xsl cannot be started as an XSLT, because it is not an XML style sheet.

may i have any other design to get my out put

cause i feel gulity asking you even the process to get the xslt processor.
i feel its troubling you a lot.


Regards
Anil





Similar Threads
Thread Thread Starter Forum Replies Last Post
Apply Paging on Grouped Data jhansib4u XSLT 4 November 26th, 2007 01:30 PM
Calculating Grouped Report Values SteveH Access 1 October 15th, 2005 03:00 PM
numbers on grouped records mkapler Access 2 March 6th, 2005 05:49 PM
Multiple controls - grouped william.murray Access 2 August 4th, 2004 04:07 AM
Averaging Grouped Data Andy Hodges SQL Language 1 April 6th, 2004 09:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.