XSLT 2.0 transformations in Switch

Post Reply
ppmg
Newbie
Posts: 8
Joined: Thu Jan 24, 2013 10:10 am

XSLT 2.0 transformations in Switch

Post by ppmg »

Hi,



Currently the XSLT transform element in Switch only supports XSLT 1.0 conversions.



We really need to be able to run 2.0 transformations via Switch. We tried differtent external XSLT parsers but they don't seem to work.



Does anyone have a solution for this?



Kind regards,



Leon Dona
tz8
Member
Posts: 84
Joined: Mon Aug 13, 2012 12:56 pm

XSLT 2.0 transformations in Switch

Post by tz8 »

Hi Leon,



we solved this by creating an external Ruby script (or PHP or whatever you would like to use for it) and call this with a script calling that as an external process. Be sure to make the script take an input file (job.getName()) and an output file (s.createPathWithName) so that you can send the output file onwards in Switch.



Cheers,



Thorsten
freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

XSLT 2.0 transformations in Switch

Post by freddyp »

Support for XSLT2.0 is an existing feature request, but can you please describe what you are trying to achieve that requires the use of XSLT2.0? I will add your comments to the feature request to give it some more "meat".



Freddy
ppmg
Newbie
Posts: 8
Joined: Thu Jan 24, 2013 10:10 am

XSLT 2.0 transformations in Switch

Post by ppmg »

Thanks tz8, i'll look into that.



Freddyp: we have to run an existing complicated XSLT 2.0 script, so there's no possible escape to 1.0...



Leon
pcobee
Newbie
Posts: 11
Joined: Fri Apr 01, 2011 5:06 pm
Location: Greenville NC
Contact:

XSLT 2.0 transformations in Switch

Post by pcobee »

This is fairly easy to set up using Saxon9...



1) download Saxon at "SaxonHE9-5-0-1N-setup.exe" at



Saxon 9.5



and install.



2) Open SwitchScripter and create a new script with the folowing properties:



Tag: propTransformCommand

Name: Transform Command

Tooltip: Indicate the Saxon "Transform" command line executable.

Inline editor: Single-line text

Editor 1: Choose file



Tag: propXslTransform

Name: XSLT Document

Tooltip: Choose the XSL transform file

Inline editor: None

Editor 1: Choose file



Copy/paste this code...





Function jobArrived(s, job)



On Error Resume Next



xsltTransformCommandPath = s.getPropertyValue("propTransformCommand")

xsltDocumentPath = s.getPropertyValue("propXslTransform")

tempOutputFilename = job.createPathWithName(job.getName())



transformCommand = """" & xsltTransformCommandPath & """ -s:""" & job.getPath() & """ -xsl:""" & _

xsltDocumentPath & """ -o:""" & tempOutputFilename & """ -ext:on"



job.log 1,transformCommand



set objShell = CreateObject("wscript.shell")

if err.number = 0 then

objShell.Run transformCommand, 1, TRUE

if err.number = 0 then

job.sendToSingle(tempOutputFilename)

else

job.fail "Error running transform [ & err.description & ]"

end if

set objShell = nothing

else

job.fail "Error trying to create WScript Object [ & err.description & ]"

end if



End Function





3) Configure the Script object by indicating the location of the "Tansform.exe" file in the Saxon installation folder as well as the XSL file.
Post Reply