Topic Options
#31469 - 07/31/09 01:44 AM Passing custom parameter value to XSLT from JobInfo
Elton Offline
Junior Member

Registered: 07/27/09
Posts: 2
Loc: Brisbane
Hi all

I have a very large XML data file (60Mb) which is normally processed by watch then sent onto print. No problem.

The Problem:
Every run we have a need to reprint some of the records contained within that file, for whatever reason.
I am able to retrieve the reference values for the data I need to reprint.
I can write an XSL stylesheet to retrieve a particular record.

What I have not been able to workout is how to provide a parameter value to the XSL stylesheet so that I can make the record extractor XSL generic.

There is no problem passing values to XSL if they are within the XML data, but in this case the value is retrieved from elsewhere and must be injected into the XSL which would then run over the data file and retrieve the record.

Has anyone attempted anything similar??

Thanks in advance.

Top
#31470 - 08/11/09 03:39 PM Re: Passing custom parameter value to XSLT from JobInfo
Benoit Potvin Offline
OL Expert

Registered: 01/02/08
Posts: 490
Loc: Montréal, Canada
Hi Elton,

Here are 2 options that you could consider:

Option 1: use and update a template XSL file with placeholders

1. Create a generic XSL file with placeholders. Let's call it xsl_template.xsl for example. This file will contain specific strings (e.g. 'IP_Address_placeholder') that will be replaced in time.

2. On your PlanetPress Workflow process, before applying XSL, first create a branch, and in that branch:
2.1 Load the generic XSL (i.e. xsl_template.xsl)
2.2. Perform as many Search and replace as needed. (e.g. replace all occurences of IP_Address_placeholder by a global variable holding an IP address like '192.168.0.1')
2.3 Save the updated xsl data file as a new XSL file in a given folder. Call it xsl_instance.xsl for example.

3. When comes the time to apply the XSL to your XML data file, use a script file instead of the embedded script. More specifically, use the xsl_instance.xsl file.

Option 2: Use an XSL script with variables

Alternatively to working with files (i.e. load, save, create, etc.), you can use the Open XSLT plugin by inserting directly the XSL code within it (i.e. Choose 'Embedded Script'). All you need to do then is to insert variables (global, local or job infos).

Hope this helps!

Benoit
_________________________
Knowledge is capital
http://twitter.com/benoitpotvin

Top
#31471 - 08/12/09 05:53 PM Re: Passing custom parameter value to XSLT from JobInfo
Elton Offline
Junior Member

Registered: 07/27/09
Posts: 2
Loc: Brisbane
Hi Benoit

Thanks for the excellent options.

I have currently implemented the function via what I would call Option 3.

The target was to pull records with particular customer references from a large data file for reprints. I have set up a web portal allowing user's to specify the references needed and I then construct the XSL file (similar to Option 1) with the relevant copy-of elements for each required reference.

The watch process is configured to look at the XSL file in a particular location, the XSL file changes its content for each reprint run.

cheers
Elton

Top