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 9:03 am
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.

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: Sun Nov 15, 2015 9:53 pm
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

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: