Robert,
Not sure it is a better way, but you can use the document structure and the
XPath preceding-sibling axis to get the same result. The attached is a
modification of your first XSL.
Best regards,
Tom Morrison
From: Robert Meyer [mailto:rme...@hotmail.co.uk]
Sent: Friday, March 15, 2013 9:31 AM
To: fop-users@xmlgraphics.apache.org
Subject: RE: Repeating elements within repeating elements
It was trickier than I first thought. I don't deal with XSLT that often but got
there in the end. I had to use an xsl:for-each as that allowed me to get the
current position and do a conditional on it. You could almost move the contents
of that template back to where it was before and just use the xsl:for-each, but
it's up to you.
There may be a better way of doing it, but hope this points you in the right
direction.
Regards,
Robert Meyer
> Date: Fri, 15 Mar 2013 05:52:51 -0700
> From: nbhc...@gmail.com<mailto:nbhc...@gmail.com>
> To: fop-users@xmlgraphics.apache.org<mailto:fop-users@xmlgraphics.apache.org>
> Subject: RE: Repeating elements within repeating elements
>
> You're a star. I did define such a template before but it didn't display any
> of the CHARGEITEMs so took it out. I see now that yours includes this line:
> <xsl:apply-templates/>
> And it seems as if it is this that makes it magically show all iterations.
> Incidentally the fields QTY, DESC, PLTS and CLASS are repeating for each
> CHARGEITEM and if I wanted to suppress the 2nd and successive occurrences
> would it be trivial to do?
>
>
>
> -----
> just starting out with FOP - don't hurt me!
> --
> View this message in context:
> http://apache-fop.1065347.n5.nabble.com/Repeating-elements-within-repeating-elements-tp38157p38159.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> fop-users-unsubscr...@xmlgraphics.apache.org<mailto:fop-users-unsubscr...@xmlgraphics.apache.org>
> For additional commands, e-mail:
> fop-users-h...@xmlgraphics.apache.org<mailto:fop-users-h...@xmlgraphics.apache.org>
>
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:common="http://exslt.org/common">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="fo-label"
page-height="29.7cm"
page-width="22.1cm"
margin="1cm"
margin-left="1cm"
margin-bottom="2cm">
<fo:region-body margin-bottom="2cm"/>
<fo:region-after region-name="footer" extent="0.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="fo-label">
<fo:static-content flow-name="footer" font-family="arial" font-size="10">
<fo:table table-layout="fixed" border="1" width="100%" space-before="40"
font-family="arial" font-size="10">
<fo:table-column column-width="16cm"/>
<fo:table-column column-width="2cm"/>
<fo:table-column column-width="2cm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block> </fo:block>
</fo:table-cell>
<fo:table-cell text-align="right">
<fo:block>INVOICE #</fo:block>
<fo:block>Account</fo:block>
<fo:block>Date</fo:block>
<fo:block>Amount Due</fo:block>
<fo:block> </fo:block>
<fo:block> </fo:block>
<fo:block>Page</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>: <xsl:value-of select="./DOCUMENT/HEADER/INVOICENO"/></fo:block>
<fo:block>: <xsl:value-of select="./DOCUMENT/HEADER/ACCOUNT"/></fo:block>
<fo:block>: <xsl:value-of select="./DOCUMENT/HEADER/INVOICEDATE"/></fo:block>
<fo:block>: <xsl:value-of select="./DOCUMENT/HEADER/AMOUNTDUE"/></fo:block>
<fo:block>: <fo:page-number/></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="DOCUMENT/HEADER">
<fo:table table-layout="fixed" border="1" width="100%" space-before="30"
font-family="arial" font-size="10">
<fo:table-column column-width="6cm"/>
<fo:table-column column-width="10cm"/>
<fo:table-column column-width="4cm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="left">
<fo:external-graphic src="url('/home/images/logo.jpg')" content-height="60%"> content-width="60"/>
</fo:external-graphic>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-weight="bold" font-style="italic">CANNINGTON</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="18" font-weight="bold" text-align="right" space-before="8" space-after="8">
TAX INVOICE
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table table-layout="fixed" border="1" width="100%"
font-family="arial" font-size="10">
<fo:table-column column-width="6cm"/>
<fo:table-column column-width="10cm"/>
<fo:table-column column-width="2cm"/>
<fo:table-column column-width="2cm"/>
<fo:table-body>
<fo:table-row>
<!-- first column-->
<fo:table-cell>
<fo:block><xsl:value-of select="./ADD1"/></fo:block>
<fo:block><xsl:value-of select="./ADD2"/></fo:block>
<fo:block><xsl:value-of select="./SUBURB"/></fo:block>
<fo:block><xsl:value-of select="./STATE"/></fo:block>
<fo:block><xsl:value-of select="./PCODE"/></fo:block>
<!-- second column-->
</fo:table-cell>
<fo:table-cell><fo:block> </fo:block></fo:table-cell>
<!-- third column-->
<fo:table-cell text-align="right">
<fo:block>TAX INVOICE</fo:block>
<fo:block>Account</fo:block>
<fo:block>Booking #</fo:block>
<fo:block>Date</fo:block>
<fo:block>Amount Due</fo:block>
</fo:table-cell>
<!-- fourth column-->
<fo:table-cell>
<fo:block>: <xsl:value-of select="./INVOICENO"/></fo:block>
<fo:block>: <xsl:value-of select="./ACCOUNT"/></fo:block>
<fo:block>: <xsl:value-of select="./BOOKINGNO"/></fo:block>
<fo:block>: <xsl:value-of select="./INVOICEDATE"/></fo:block>
<fo:block>: <xsl:value-of select="./AMOUNTDUE"/></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template match="DOCUMENT/NOTE">
<fo:table>
<fo:table-column column-width="26cm"/>
<fo:table-body>
<fo:table-row>
<!-- first and only column-->
<fo:table-cell>
<fo:block>
_______________________________________________________________________________________________________________
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table table-layout="fixed" border="1" width="100%" font-family="arial" font-size="10">
<fo:table-column column-width="6cm"/>
<fo:table-column column-width="8cm"/>
<fo:table-column column-width="8cm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="left">
note : <xsl:value-of select="./NUMBER"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="left">
Send: <xsl:value-of select="./SENDER"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="left">
Rec: <xsl:value-of select="./RECEIVER"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="left">
Cust Ref : <xsl:value-of select="./CUSTREF"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="left">
P/U : <xsl:value-of select="./PICKUP"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="left">
Del: <xsl:value-of select="./DELIVER"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table table-layout="fixed" border="1" width="100%" space-before="10" font-family="arial" font-size="10">
<fo:table-column column-width="1cm"/>
<fo:table-column column-width="6cm"/>
<fo:table-column column-width="1cm"/>
<fo:table-column column-width="2cm"/>
<fo:table-column column-width="2cm"/>
<fo:table-column column-width="1cm"/>
<fo:table-column column-width="5cm"/>
<fo:table-column column-width="4cm"/>
<fo:table-body>
<fo:table-row font-weight="bold">
<fo:table-cell> <fo:block>Qty</fo:block> </fo:table-cell>
<fo:table-cell> <fo:block>Description</fo:block> </fo:table-cell>
<fo:table-cell> <fo:block>Plts</fo:block> </fo:table-cell>
<fo:table-cell> <fo:block>Class</fo:block> </fo:table-cell>
<fo:table-cell text-align="right"> <fo:block>Units</fo:block> </fo:table-cell>
<fo:table-cell> <fo:block> </fo:block> </fo:table-cell>
<fo:table-cell
white-space-collapse="false"
white-space-treatment="preserve">
<fo:block>Charge Ord# <xsl:value-of select="./ORDERNO"/></fo:block> </fo:table-cell>
<fo:table-cell> <fo:block>Date: <xsl:value-of select="./ORDERDATE"/></fo:block> </fo:table-cell>
</fo:table-row>
<xsl:apply-templates/>
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template match="DOCUMENT/NOTE/LINEITEMS/LINEITEM/CHARGEITEMS/CHARGEITEM">
<fo:table-row>
<xsl:choose>
<xsl:when test="count(preceding-sibling::*) = 0">
<fo:table-cell>
<fo:block>a<xsl:value-of select="../../QTY"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="../../DESC"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="../../PLTS"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="../../CLASS"/></fo:block>
</fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
</xsl:otherwise>
</xsl:choose>
<fo:table-cell text-align="right">
<fo:block><xsl:value-of select="./UNITS"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block> </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="./CHARGE"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block> </fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org