 |
| 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
|
|
|
|

February 13th, 2009, 02:55 PM
|
|
Registered User
|
|
Join Date: May 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Adding similiar occurences with loop
How can I add similiar occurrences of a node in xslt:
Like
Abc 12.00
EFT 3
Abc 12.00
Eft 4
Abc 11
Eft 2
I want it to b
Abc 35
eft 9
Thankx in advance
|
|

February 13th, 2009, 06:16 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
1. What does your input look like?
2. Are you using XSLT 1.0 or 2.0? (Most things are easier in 2.0....)
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|

February 16th, 2009, 10:06 AM
|
|
Registered User
|
|
Join Date: May 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
its something like
<PersVeh id="v1" LocationRef="" RatedDriverRef="d1">
<ItemIdInfo>
<InsurerId>1</InsurerId>
</ItemIdInfo>
<Coverage>
<CoverageCd>ATFEE</CoverageCd>
<CoverageDesc/>
<Deductible>
<FormatCurrencyAmt>
<Amt/>
</FormatCurrencyAmt>
<DeductibleTypeCd/>
</Deductible>
<CurrentTermAmt>
<Amt>0.50</Amt>
</CurrentTermAmt>
</Coverage>
<Coverage>
<CoverageCd>BI</CoverageCd>
<CoverageDesc/>
<Limit>
<FormatCurrencyAmt>
<Amt>15/30</Amt>
</FormatCurrencyAmt>
</Limit>
<Deductible>
<FormatCurrencyAmt>
<Amt/>
</FormatCurrencyAmt>
<DeductibleTypeCd/>
</Deductible>
<CurrentTermAmt>
<Amt>146.30</Amt>
</CurrentTermAmt>
</Coverage>
<Coverage>
<CoverageCd>CMP</CoverageCd>
<CoverageDesc/>
<Deductible>
<FormatCurrencyAmt>
<Amt/>
</FormatCurrencyAmt>
<DeductibleTypeCd/>
</Deductible>
<CurrentTermAmt>
<Amt>96.50</Amt>
</CurrentTermAmt>
</Coverage>
<Coverage>
<CoverageCd>COL</CoverageCd>
<CoverageDesc/>
<Deductible>
<FormatCurrencyAmt>
<Amt/>
</FormatCurrencyAmt>
<DeductibleTypeCd/>
</Deductible>
<CurrentTermAmt>
<Amt>281.40</Amt>
</CurrentTermAmt>
</Coverage>
<Coverage>
<CoverageCd>MP</CoverageCd>
<CoverageDesc/>
<Limit>
<FormatCurrencyAmt>
<Amt>1</Amt>
</FormatCurrencyAmt>
</Limit>
<Deductible>
<FormatCurrencyAmt>
<Amt/>
</FormatCurrencyAmt>
<DeductibleTypeCd/>
</Deductible>
<CurrentTermAmt>
<Amt>16.50</Amt>
</CurrentTermAmt>
</Coverage>
<Coverage>
<CoverageCd>PD</CoverageCd>
<CoverageDesc/>
<Limit>
<FormatCurrencyAmt>
<Amt>10</Amt>
</FormatCurrencyAmt>
</Limit>
<Deductible>
<FormatCurrencyAmt>
<Amt/>
</FormatCurrencyAmt>
<DeductibleTypeCd/>
</Deductible>
<CurrentTermAmt>
<Amt>85.70</Amt>
</CurrentTermAmt>
</Coverage>
<Coverage>
<CoverageCd>RP</CoverageCd>
<CoverageDesc>Replacement Cost</CoverageDesc>
</Coverage>
<Coverage>
<CoverageCd>LL</CoverageCd>
<CoverageDesc>Loan / Lease GAP</CoverageDesc>
</Coverage>
</PersVeh>
<PersVeh id="v2" LocationRef="" RatedDriverRef="d1">
<ItemIdInfo>
<InsurerId>1</InsurerId>
</ItemIdInfo>
<Coverage>
<CoverageCd>ATFEE</CoverageCd>
<CoverageDesc/>
<Deductible>
<FormatCurrencyAmt>
<Amt/>
</FormatCurrencyAmt>
<DeductibleTypeCd/>
</Deductible>
<CurrentTermAmt>
<Amt>0.50</Amt>
</CurrentTermAmt>
</Coverage>
<Coverage>
<CoverageCd>BI</CoverageCd>
<CoverageDesc/>
<Limit>
<FormatCurrencyAmt>
<Amt>15/30</Amt>
</FormatCurrencyAmt>
</Limit>
<Deductible>
<FormatCurrencyAmt>
<Amt/>
</FormatCurrencyAmt>
<DeductibleTypeCd/>
</Deductible>
<CurrentTermAmt>
<Amt>146.30</Amt>
</CurrentTermAmt>
</Coverage>
<Coverage>
<CoverageCd>CMP</CoverageCd>
<CoverageDesc/>
<Deductible>
<FormatCurrencyAmt>
<Amt/>
</FormatCurrencyAmt>
<DeductibleTypeCd/>
</Deductible>
<CurrentTermAmt>
<Amt>96.50</Amt>
</CurrentTermAmt>
</Coverage>
<Coverage>
<CoverageCd>COL</CoverageCd>
<CoverageDesc/>
<Deductible>
<FormatCurrencyAmt>
<Amt/>
</FormatCurrencyAmt>
<DeductibleTypeCd/>
</Deductible>
<CurrentTermAmt>
<Amt>281.40</Amt>
</CurrentTermAmt>
</Coverage>
<Coverage>
<CoverageCd>MP</CoverageCd>
<CoverageDesc/>
<Limit>
<FormatCurrencyAmt>
<Amt>1</Amt>
</FormatCurrencyAmt>
</Limit>
<Deductible>
<FormatCurrencyAmt>
<Amt/>
</FormatCurrencyAmt>
<DeductibleTypeCd/>
</Deductible>
<CurrentTermAmt>
<Amt>16.50</Amt>
</CurrentTermAmt>
</Coverage>
<Coverage>
<CoverageCd>PD</CoverageCd>
<CoverageDesc/>
<Limit>
<FormatCurrencyAmt>
<Amt>10</Amt>
</FormatCurrencyAmt>
</Limit>
<Deductible>
<FormatCurrencyAmt>
<Amt/>
</FormatCurrencyAmt>
<DeductibleTypeCd/>
</Deductible>
<CurrentTermAmt>
<Amt>85.70</Amt>
</CurrentTermAmt>
</Coverage>
<Coverage>
<CoverageCd>RP</CoverageCd>
<CoverageDesc>Replacement Cost</CoverageDesc>
</Coverage>
<Coverage>
<CoverageCd>LL</CoverageCd>
<CoverageDesc>Loan / Lease GAP</CoverageDesc>
</Coverage>
</PersVeh>
and i want ATFEE 1
BI 296.4
on the basic of Coverage/CurrentTermAmt/Amt
Thankx
|
|

February 16th, 2009, 10:23 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
>and i want ATFEE 1
BI 296.4
on the basic of Coverage/CurrentTermAmt/Amt
I'm sorry, if that's the requirement that you are working to, then I don't understand it.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|

February 17th, 2009, 01:53 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
I don't know how you got the sum BI 296.4. Just check once.
With XSLT 2.0, try this:
Code:
<xsl:template match="root">
<xsl:variable name="node" select="//Amt"></xsl:variable>
<xsl:for-each select="distinct-values(//CoverageCd)">
<xsl:variable name="name">
<xsl:value-of select="."></xsl:value-of>
</xsl:variable>
<xsl:value-of select="$name"></xsl:value-of><xsl:text> = </xsl:text>
<xsl:value-of select="sum($node[../../CoverageCd = $name])"></xsl:value-of>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
__________________
Rummy
|
|

February 17th, 2009, 07:27 PM
|
|
Registered User
|
|
Join Date: May 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thankx Rummy,
But it is saying distinct-values() is an unknow xslt function.Even i have
<xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="2.0">
on the top?
|
|

February 17th, 2009, 07:39 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
You're probably using an XSLT processor that doesn't support XSLT 2.0 yet. Many don't. If you can use an XSLT 2.0 processor, your life will be much easier.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|

February 18th, 2009, 12:18 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
As Mike has said, find the XSLT processor you are using. And also check whether it supports. When you run a XSLT 2.0 stylesheet with XSLT 1.0 processor, probably you might get an error message. Use latest version of Saxon processor which supports XSLT 2.0.
__________________
Rummy
|
|
 |