|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Subtotals by page
Now what I actually want is the page total on this page: which would be the value I get when I subtract the above two values like this: pagetotal - partsum In XSL-FO it is not possible to do this. instead of struggling with your XSLT, why not make your XML easier to work with..... take the following example xml which represents an simple order EXAMPLE XML <?xml version="1.0" encoding="UTF-8"?> <order> <item name="a" price="1.00"/> <item name="b" price="1.00"/> <item name="c" price="2.00"/> <item name="d" price="1.00"/> <item name="e" price="2.00"/> <item name="f" price="1.00"/> <item name="g" price="1.00"/> <item name="h" price="1.00"/> <item name="i" price="2.00"/> <item name="j" price="1.00"/> <item name="k" price="2.00"/> <item name="l" price="1.00"/> </order> wouldnt it be easier to supply your XSLT with something like; DESIRED XML <?xml version="1.0" encoding="utf-8"?> <page> <item name="a" price="1.00"/> <item name="b" price="1.00"/> <item name="c" price="2.00"/> <item name="d" price="1.00"/> <item name="e" price="2.00"/> </page> <page> <item name="f" price="1.00"/> <item name="g" price="1.00"/> <item name="h" price="1.00"/> <item name="i" price="2.00"/> <item name="j" price="1.00"/> </page> <page> <item name="k" price="2.00"/> <item name="l" price="1.00"/> </page> the XML has segreated 5 <item/>'s per <page/> element there are a variety of ways to achieve this type of grouping, the following is one way using mod and position() and xsl:for-each EXAMPLE XSLT <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml"/> <xsl:template match="order"> <xsl:for-each select="item[position() mod 5 = 1]"> <page> <xsl:for-each select=".|following-sibling::item[position() <5]"> <xsl:copy-of select="."/> </xsl:for-each> </page> </xsl:for-each> </xsl:template> </xsl:stylesheet> by having the first stage of XSLT processing massage your XML into a paged format makes the 2nd stage much easier to perform your sum() operations to obtain subtotal and total sums. gl, Jim Fuller
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








