You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by nels <nb...@gmail.com> on 2013/03/15 12:00:18 UTC

Repeating elements within repeating elements

Sorry if I am using the wrong terminology and correct me if it is wrong.
I am producing a PDF from an XML document using my own XSLFO style sheet.
The XML document can contain many NOTEs and each can contain many
CHARGEITEMs. The resultant PDF generated only contains the first CHARGEITEM.
This sample contains two NOTEs, the first has one CHARGEITEM the second has
two. 
sample.xml <http://apache-fop.1065347.n5.nabble.com/file/n38157/sample.xml>  
sample.xsl <http://apache-fop.1065347.n5.nabble.com/file/n38157/sample.xsl>  
sample.pdf <http://apache-fop.1065347.n5.nabble.com/file/n38157/sample.pdf>  
Three files attached are the XML, XSLFO and output PDF. Any help or advice
greatly appreciated.



-----
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-tp38157.html
Sent from the FOP - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


RE: Repeating elements within repeating elements

Posted by Thomas Morrison <Th...@microfocus.com>.
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:rmeyer@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: nbhchan@gmail.com<ma...@gmail.com>
> To: fop-users@xmlgraphics.apache.org<ma...@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-unsubscribe@xmlgraphics.apache.org<ma...@xmlgraphics.apache.org>
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org<ma...@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
______________________________________________________________________

RE: Repeating elements within repeating elements

Posted by Robert Meyer <rm...@hotmail.co.uk>.
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: nbhchan@gmail.com
> To: 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-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
 		 	   		  

RE: Repeating elements within repeating elements

Posted by nels <nb...@gmail.com>.
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-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


RE: Repeating elements within repeating elements

Posted by Robert Meyer <rm...@hotmail.co.uk>.
Hi,

I think you were missing a template match for each CHARGEITEM, and therefore it would only ever match the first one. I am not fully sure how you wanted it displayed, but I have attached a modified version of the XSL document with the output PDF as an example.

Hope this helps,

Regards,

Robert Meyer

> Date: Fri, 15 Mar 2013 04:00:18 -0700
> From: nbhchan@gmail.com
> To: fop-users@xmlgraphics.apache.org
> Subject: Repeating elements within repeating elements
> 
> Sorry if I am using the wrong terminology and correct me if it is wrong.
> I am producing a PDF from an XML document using my own XSLFO style sheet.
> The XML document can contain many NOTEs and each can contain many
> CHARGEITEMs. The resultant PDF generated only contains the first CHARGEITEM.
> This sample contains two NOTEs, the first has one CHARGEITEM the second has
> two. 
> sample.xml <http://apache-fop.1065347.n5.nabble.com/file/n38157/sample.xml>  
> sample.xsl <http://apache-fop.1065347.n5.nabble.com/file/n38157/sample.xsl>  
> sample.pdf <http://apache-fop.1065347.n5.nabble.com/file/n38157/sample.pdf>  
> Three files attached are the XML, XSLFO and output PDF. Any help or advice
> greatly appreciated.
> 
> 
> 
> -----
> 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-tp38157.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>