[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] And I'd like that in triplicate...


Subject: RE: [xsl] And I'd like that in triplicate...
From: "Ferry, Jeremy" <Jeremy_Ferry@xxxxxxxxxxxx>
Date: Thu, 27 Mar 2008 15:36:10 -0500

I'll definitely look into tunnel parameters in XSLT 2.0 since I've got
multiple layers of templates to pass them through. But for now, I've got
it working with your suggestions.

Ken, Wendell, thanks very much for the help!

-----Original Message-----
From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx]
Sent: Wednesday, March 19, 2008 2:11 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] And I'd like that in triplicate...

Jeremy,

Adding to what Ken said....

The first decision you'll have to make is whether you want the three
copies as a single PDF, or as multiple PDFs. If the former, you will
would most likely generate each of the three copies as a separate
page-sequence. In that case your stylesheet would having something
logically like this:

<xsl:template match="/">
   <fo:root>
     <xsl:call-template name="page-architecture"/>
     <xsl:apply-templates>
       <xsl:with-param name="copy" select="'merchant'"/>
     </xsl:apply-templates>
     <xsl:apply-templates>
       <xsl:with-param name="copy" select="'customer'"/>
     </xsl:apply-templates>
     <xsl:apply-templates>
       <xsl:with-param name="copy" select="'file'"/>
     </xsl:apply-templates>
   </fo:root>
</xsl:template>

where a page sequence results from each apply-templates traversal.

In other words, perform the same logic three times, but pass a parameter
in to differentiate between them.

Then, when you generate your content, you test against the value of your
parameter to determine which copy you're making.

This is easier to implement in XSLT 2.0, which has a feature called
"tunnel parameters", which allows you to avoid having to pass your
parameters explicitly through every template you use. This is
cumbersome, but unfortunately necessary in XSLT 1.0.

If you want three separate PDFs, you can declare your parameters at the
top level and pass them in at runtime. This is a bit easier in 1.0,
since global parameters are available in every template and thus don't
have to be passed through explicitly. To run this, you'd simple invoke
your stylesheet on your document three times, setting the parameter
value differently for each.

Either way, the answer to the question "How do I do exactly the same
thing with minor exceptions three ways" is simply to do the thing three
times, using a parameter to drive the differentiations.

Look up xsl:param and xsl:with-param for more. Use tunnel parameters in
XSLT 2.0 if you can.

Cheers,
Wendell

At 02:49 PM 3/19/2008, you wrote:
>At 2008-03-19 12:50 -0500, Ferry, Jeremy wrote:
>>I've got a xsl-fo stylesheet that I've created to output an xml
>>document as a PDF but I'm having trouble figuring out how I would
>>produce multiple copies, each one having only minor differences in
>>some static content. Think of it like a credit card receipt - one copy

>>for the merchant and one for the customer - the only difference being
>>the text that says "Merchant Copy" or "Customer Copy".
>
>There is nothing in XSL-FO that automatically replicates content for a
>specific number of iterations ... if you want three copies, then you
>have to generate all three copies during your transformation stage, and

>then format the collection of three copies found in your generated
>XSL-FO.
>
>As to the minor variances, if you meant "static content"
>generically, then you would do this during your transformation creating

>the three copies with a slight difference through typical XSLT logic.
>
>If you meant "Static Content" as in header and footer content of an
>XSL-FO instance, then you have the option of using the identical XSLT
>logic three times, where in the header you retrieve a marker of a given

>name each time.  Then in your XSLT you just define the marker content
>before creating each of the copies of the receipt content.
>
>I hope this helps.
>
>. . . . . . . . . . . Ken
>
>
>--
>Upcoming:  UBL Apr.22,24; genericode code lists Apr.23; Rome,Italy
>World-wide corporate, govt. & user group XML, XSL and UBL training
>RSS feeds:     publicly-available developer resources and training
>G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
>Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
>Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
>Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
>Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


Current Thread
Keywords