Page 1 of 1

xml data & HP digital front end JDF Control

Posted: Mon Oct 12, 2015 4:23 pm
by abonsey
We have xml data coming in that contains multiple entries. Each entry refers to a file path, stock, quantity etc.
What I'm trying to do is link this up with the JDF control to send straight to the press for outputting.
Can this be done from a single XML without splitting?
If it has to be split can anybody advise on best practice or example?

TIA

Re: xml data & HP digital front end JDF Control

Posted: Mon Oct 12, 2015 5:07 pm
by gabrielp
You could probably do an XSLT transform to get separate files you can inject into your flow to run through the JDF configurator. I haven't done an XSLT transform that produces more than a single output file though, so I'm not sure if that's entirely possible. If not, then you'd probably have to write a script that would loop through your XML and output separate jobs for each record in the XML.

Re: xml data & HP digital front end JDF Control

Posted: Mon Oct 12, 2015 7:39 pm
by sander
The XSLT transform configurator only supports XSLT 1.0. You need XSLT 2.0 to split your XML. Enfocus tipped me once to use Saxon for this (http://saxon.sourceforge.net), which I believe the configurator is included in Switch 13. I haven't tested with this configurator yet, I'm still running Switch 12u3.

Anyway, I use it this way:
Image

Arguments (in my case):

Code: Select all

"%1" "D:\Scripts\Saxon\[Job.JobState].xsl" "%2\output.xml"
XSL:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
    <xsl:template match="/">
        <xsl:for-each select="order/artikelen/artikel/bestanden/bestand">
        	<xsl:variable name="InputFile" select="base-uri()"/>
			<xsl:variable name="OutputFile" select="tokenize($InputFile,'/')[last()]"/>
        	<xsl:variable name="OutputNoExt" select="substring-before($OutputFile,'.')"/>
	    	<xsl:result-document href="{$OutputNoExt}_{format-number(position(),'000')}.xml" method="xml">
			<xsl:copy-of select="current()/../.."/>
            </xsl:result-document>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>
In my case I use it to split XML's with a unknown number of <file> nodes, so I can't use static pickup's.

Hope it helps,

Re: xml data & HP digital front end JDF Control

Posted: Mon Oct 12, 2015 9:15 pm
by gabrielp
Thanks for sharing your solution, sander. That is good information to know. :)

Re: xml data & HP digital front end JDF Control

Posted: Mon Oct 12, 2015 11:15 pm
by abonsey
Thanks for the info.

Re: xml data & HP digital front end JDF Control

Posted: Mon Oct 12, 2015 11:24 pm
by dkelly
yes, Switch 13 has a Saxon configurator built-in

Re: xml data & HP digital front end JDF Control

Posted: Tue Oct 27, 2015 6:08 pm
by sander
The screenshots might be a little confusing, since I'm passing Switch variables %1 and %2 to Saxon.cmd, which catches these and use it otherwise.

The command I'm executing is Saxon.cmd, and this batch file holds this:

Code: Select all

C:\ProgramData\Oracle\Java\javapath\java.exe -jar "D:\Scripts\Saxon\build\saxon9he.jar" -s:%1 -xsl:%2 -o:%3 >> "D:\Scripts\Saxon\SaxonError.log" 2>&1
" >> "D:\Scripts\Saxon\SaxonError.log" 2>&1" is logging for batch files in Windows, you can ignore that.

Switch argument input:

Code: Select all

"%1" "D:\Scripts\Saxon\[Job.JobState].xsl" "%2\output.xml"
So my batch file catches the input this way:
Batch %1 catches "%1"
Batch %2 catches "D:\Scripts\Saxon\[Job.JobState].xsl"
Batch %3 catches "%2\output.xml"

Hmm, too much information how my setup works! Let's go find a Mac solution, I'm not that experienced with Mac's but let's give it a try.

In your Command or Path you can try to specify your path to java with the Saxon jar:
path/to/java -jar path/to/saxon9he.jar

Your arguments need something like this:
-s:%1 -xsl:path/to/stylesheet.xsl -o:%2\output.xml

Notice the %2 at the end, it's not %3 like in my batch file!

Actually output.xml is not necessary since the XLS stylesheet does the file naming, however I couldn't get Saxon to work without specifying the output file.

I hope you can get it to work this way, else we need a way to 'translate' my Saxon.cmd to a Mac version, I hope some other forum member can join in to help us with that!

Re: xml data & HP digital front end JDF Control

Posted: Mon Nov 16, 2015 9:42 am
by sander
Cool, good to know you figured it out, and thanks for sharing!

Now I notice your username I finally know were Rien was Lyncing about last week :lol: