xml data & HP digital front end JDF Control

Post Reply
abonsey
Member
Posts: 98
Joined: Fri May 24, 2013 5:10 pm

xml data & HP digital front end JDF Control

Post 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
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: xml data & HP digital front end JDF Control

Post 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.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
sander
Advanced member
Posts: 228
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: xml data & HP digital front end JDF Control

Post 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,
Part of my playground:
- HP Indigo 10k, HP Indigo 7600's (full options), Highcon Euclid III, Zünd S3
- HP Production Pro 6.0.1, HP Production Center 2.5.1 beta, Apogee 9.1, Enfocus Switch 13u1 & PitStop Server 13u2.

Chat: open-automation @ gitter
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: xml data & HP digital front end JDF Control

Post by gabrielp »

Thanks for sharing your solution, sander. That is good information to know. :)
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
abonsey
Member
Posts: 98
Joined: Fri May 24, 2013 5:10 pm

Re: xml data & HP digital front end JDF Control

Post by abonsey »

Thanks for the info.
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Re: xml data & HP digital front end JDF Control

Post by dkelly »

yes, Switch 13 has a Saxon configurator built-in
kevinjel
Newbie
Posts: 8
Joined: Thu Jun 11, 2015 10:42 am

Re: xml data & HP digital front end JDF Control

Post by kevinjel »

Fellow switch users,

i'm currently working on this challenge, the difference from Sander his example is i'm running switch 12 in a mac environment.
2 questions;
i have made my xsl, i've installed saxon on the machine, i can get it to work locally (myself typing it on the command line) tho i can't seem to get it working via Switch. In Switch there is: "command or path" should this be a (remember mac) .command file to the path of Saxon? so will this be: "cd /Applications/Saxon/" so the path is set, then the arguments are: "java -jar saxon9he.jar -xsl:/Applications/Saxon/xsl/transformxslt_v2.xsl -s:/Users/administrator/Library/Application\ Support/Enfocus/Switch\ Server/backing/xml\ pickup/automanaged/samengestelde\ order/[Job.Name] -o:/Users/administrator/Library/Application\ Support/Enfocus/Switch\ Server/backing/xml\ pickup/automanaged/singleXML/out.xml"

i'm new to Switch so go easy please ;)

Then question nr.2;
I cant' wrap my head around the %1 - %2 - %3 or how that works in Switch. Should i do : "%1" "path to input file/folder" or can i just do "path to input file/folder" or i need to use the %1. Is there any introduction to this, maybe an example video. i'm eager to learn.

Thanks in advance.
sander
Advanced member
Posts: 228
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: xml data & HP digital front end JDF Control

Post 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!
Part of my playground:
- HP Indigo 10k, HP Indigo 7600's (full options), Highcon Euclid III, Zünd S3
- HP Production Pro 6.0.1, HP Production Center 2.5.1 beta, Apogee 9.1, Enfocus Switch 13u1 & PitStop Server 13u2.

Chat: open-automation @ gitter
kevinjel
Newbie
Posts: 8
Joined: Thu Jun 11, 2015 10:42 am

Re: xml data & HP digital front end JDF Control

Post by kevinjel »

oke, it's been some time but the good news is... it's fixed :)

To help other mac Switchers the following was wrong;
instead of the .command file i've created a .sh file (with full executable rights) which contains:

Code: Select all

#! /bin/sh

/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/bin/java -jar /Applications/Saxon/saxon9he.jar -s:"$1" -xsl:/pathToMyXsl.xsl -o:"$2"
so that is: path to java, then -jar, then path to saxon.jar file, then -s"$1" which is the incoming job in Switch, -xsl: the path towards the xsl, -o:"$2" the output file.

the "$1" and "$2" are defined in the arguments:

Code: Select all

"%1" /pathWhereYouWantOutputFiles/out.xml
note: i use out.xml since i rename the files within my xsl.

output = file at path

I don't know if the %1 in the command or path (the .sh) will work, don't have the time to test this, tho the $ way works for me (maybe mac environment only?) anyway. Thanks for giving me some guidance Sander. Switch 13 has xslt 2.0 build in, just don't have the time to upgrade yet.

Greetings
sander
Advanced member
Posts: 228
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: xml data & HP digital front end JDF Control

Post 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:
Part of my playground:
- HP Indigo 10k, HP Indigo 7600's (full options), Highcon Euclid III, Zünd S3
- HP Production Pro 6.0.1, HP Production Center 2.5.1 beta, Apogee 9.1, Enfocus Switch 13u1 & PitStop Server 13u2.

Chat: open-automation @ gitter
Post Reply