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 February 27th, 2017, 02:42 PM
Authorized User
 
Join Date: Apr 2010
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
Default How To Call Same Template Multiple Times Within a Template

Hello.

I have an XML file with parent tag <CLAIMCONTACT>that can appear n number of times. For each <CLAIMCONTACT> I need to generate a PDF file.

I'm using xslt and FO commands within my xml_pdf.fo file that reads the XML file. My final outcome from this xml_pdf.fo file is to always generate one PDF file. Then, for each occurrence of the <CLAIMCONTACT> tag, generate another copy of the same PDF along with a cover sheet in front.

Is this at all possible? Call xml_pdf.fo from within xml_pdf.fo to generate multiple copies of the PDF.

For example, if my XML file contains two <CLAIMCONTACT> tags, the output from xml_pdf.fo will be one PDF file with no cover sheet, then two of the same PDF file with the cover sheet as the first page.

Another idea I had was to print multiple copies of the PDF within the XSLT code, depending on the occurrences of <CLAIMCONTACT>.
Is there code available to do this?
I Googled it but could not find anything.
I current have the cover sheets printing correctly - one per <CLAIMCONTACT>.
Now I just need to get the PDF file that's generated from all the XML code for each cover sheet created.

Something else I'm trying to figure out is how to call/execute another fo file from within xml_pdf.fo.
Then within my <CLAIMCONTACT> <xsl:for-each ...> loop, I'll process the other fo file.
Here's my looping code:
Code:
<fo:simple-page-master master-name="disclaimer" page-height="27.94cm" page-width="21.59cm" margin-top="0.5cm" margin-bottom="1cm" margin- left="1cm" margin-right="1cm">
   <fo:region-body region-name="disclaimer"/>
</fo:simple-page-master>

      <!-- DEFINE PAGE SEQUENCE - (Attorney Cover Page(s)) -->
      <xsl:if test="/doc/EOB/CLAIMCONTACT/NUMBER[.!=''] and $varInfo='Y'">
        <xsl:for-each select="/doc/EOB/CLAIMCONTACT">
          <fo:page-sequence master-reference="disclaimer" force-page-count="no-force">
            <fo:flow flow-name="disclaimer">
              <fo:block xsl:use-attribute-sets="attributes_NYNF">
                <fo:block padding="0pt" font-size="1pt">
                </fo:block>
                <xsl:call-template name="tmpAttorneyCoverPage">
                  <xsl:with-param name="vFirmName">
                    <xsl:value-of select="COMPANY_NAME"/>
                  </xsl:with-param>
                </xsl:call-template>
              </fo:block>
            </fo:flow>
          </fo:page-sequence>
        </xsl:for-each>
      </xsl:if>
I'm thinking this will be my best solution if possible!

Any suggestions will be greatly appreciated!

Thanks,
Rita

Last edited by ritagr; February 27th, 2017 at 08:00 PM..
 
Old February 28th, 2017, 01:20 PM
Authorized User
 
Join Date: Apr 2010
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
Default

So after trying about thirty variations, I was able to get the code to work.
Instead of using <xsl:call-template> I changed it to <xsl:apply-template> with match="/doc" (so within the loop my XML code would be passed on to the template).





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use recursive apply vs call template FXYLDY XSLT 2 June 15th, 2010 01:57 PM
anyway to call a template with a lower precedence? ojasrege XSLT 3 November 30th, 2007 12:13 PM
Using Parameter to call another template mikevn123 XSLT 1 October 27th, 2006 03:08 PM
how to use call-template result in a test? briforge XSLT 6 February 13th, 2006 06:54 PM
import / call / template match Kabe XSLT 3 February 26th, 2004 11:31 AM





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