XProc and XSL-FO

Here should go questions about transforming XML with XSLT and FOP.
willisd1
Posts: 8
Joined: Fri Jan 23, 2009 4:46 pm

XProc and XSL-FO

Post by willisd1 »

I have been looking for examples on the web and trying to find the correct way to run my FO stylesheets using XProc in Oxygen 11.2...so far, unsuccessfully.

Could someone please help me locate the problem:

Code: Select all

<p:declare-step version="1.0" xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step" name="main">

<p:input port="source">
<p:document href="MT_Columbus.xml"/>
</p:input>
<p:input port="parameters" kind="parameter"/>
<p:output port="result">
<p:pipe step="step_2" port="result"/>
</p:output>

<p:xslt name="step_1">
<p:input port="stylesheet">
<p:document href="FO_InspectionReport_Followup.xsl"/>
</p:input>
<p:input port="parameters">
<p:empty/>
</p:input>
</p:xslt>

<p:xsl-formatter href="report.pdf" name="step_2"/>

</p:declare-step>
Thanks, Sean
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: XProc and XSL-FO

Post by sorin_ristache »

Hello,

Sorry for replying so late. You can find below an example of xsl-formatter element for an XSL-FO transformation:

Code: Select all

<p:xsl-formatter name="xep" href="test.pdf" content-type="application/pdf">
<p:input port="source"/>
<p:input port="parameters">
<p:empty/>
</p:input>
</p:xsl-formatter>
Also you have to add the XEP library files to the configuration file of the XProc engine. XEP is the only FO processor supported yet by the Calabash XProc processor (Calabash version 0.9.21 up to now). At the end of the file [Oxygen-install-folder]/lib/xproc/calabash/engine.xml you can find the following 4 commented lines:

Code: Select all

  <!-- Builtin XEP libraries and configuration 
<library name="../../../tools/xep/lib/patch.jar"/>
<library name="../../../tools/xep/lib/xep.jar"/>
<library name="../../../tools/xep/lib/xt.jar"/>
<system-property name="com.renderx.xep.CONFIG" file="../../../tools/xep/xep.xml"/>
-->
You will have to uncomment them and make sure that they point to the correct paths of the XEP files. The XEP processor does not come with Oxygen so you will need a separate license for it.


Regards,
Sorin
kw1
Posts: 2
Joined: Thu May 27, 2010 3:32 pm

Re: XProc and XSL-FO

Post by kw1 »

I also have been unsuccessful at getting oXygen/Calabash/XEP configured to run an XSL-FO transform, and would be very grateful for any help. I do have XEP (v4.18-20100322) installed and running with no problems within oXygen (v11.2 build 2010041213) transformation scenarios.

The error I'm getting is "[Calabash XProc] com/renderx/xep/FormatterImpl", and at this point I'm not sure whether the problem is with the XProc script or with the configuration of oXygen/Calabash/XEP.

I have edited the /lib/xproc/calabash/engine.xml file to uncomment the pointers to the XEP library files, but have noted that one of the files ("patch.jar") does not exist in the XEP/lib directory (also, there are several jar files in that directory which are not referenced in the Calabash configuration file). My XEP directory is a sibling of my oXygen directory, and I assume that the working directory is that containing the Calabash config file, so I changed the file paths:

Code: Select all

<library name="../../../../XEP/lib/patch.jar"/>
<library name="../../../../XEP/lib/xep.jar"/>
<library name="../../../../XEP/lib/xt.jar"/>
<system-property name="com.renderx.xep.CONFIG" file="../../../../XEP/xep.xml"/>
I've tried several combinations of removing the reference to the "patch.jar" file and adding references to the other jar files in the XEP/lib directory.

The XProc script I'm working with:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0" name="galley_biblio">

<p:input port="source" primary="true">
<p:document href="../../../driver.xml"></p:document>
</p:input>

<p:output port="result">
<p:pipe step="xep" port="result"/>
</p:output>

<p:xslt name="bibliography-rend">
<p:input port="source"/>
<p:input port="stylesheet">
<p:document href="../!parts/bibliography-rend.xsl"/>
</p:input>
<p:input port="parameters"><p:empty/></p:input>
</p:xslt>

<p:xslt name="bibliography-pdf">
<p:input port="source">
<p:pipe port="result" step="bibliography-rend"/>
</p:input>
<p:input port="stylesheet">
<p:document href="../!parts/bibliography-pdf.xsl"/>
</p:input>
<p:input port="parameters"><p:empty/></p:input>
</p:xslt>

<p:xsl-formatter name="xep" href="../xoutput/bibliography.pdf" content-type="application/pdf">
<p:input port="source">
<p:pipe port="result" step="bibliography-pdf"/>
</p:input>
<p:input port="parameters"><p:empty/></p:input>
</p:xsl-formatter>

</p:declare-step>
I also tried a new installation of oXygen (build 2010051111), with a fresh installation of XEP (v4.18-20100322) in the oXygen/tools/ directory, and uncommented the XEP references in the Calabash configuration file. When I tried to run the XProc within this installation, I received this error:

Code: Select all

loader constraint violation: when resolving method "net.sf.saxon.s9api.DocumentBuilder.build(Ljavax/xml/transform/Source;)Lnet/sf/saxon/s9api/XdmNode;" the class loader (instance of ro/sync/util/l) of the current class, com/xmlcalabash/core/XProcConfiguration, and the class loader (instance of ro/sync/util/yb) for resolved class, net/sf/saxon/s9api/DocumentBuilder, have different Class objects for the type javax/xml/transform/Source used in the signature
I'd be very grateful if someone could point out the error of my ways...
Mircea
Posts: 131
Joined: Tue Mar 25, 2003 11:21 am

Re: XProc and XSL-FO

Post by Mircea »

Hello,

Thank you for reporting this problem. We will investigate it.

Mircea.
Mircea Enachescu
<oXygen> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Mircea
Posts: 131
Joined: Tue Mar 25, 2003 11:21 am

Re: XProc and XSL-FO

Post by Mircea »

Hello,

The first error
"[Calabash XProc] com/renderx/xep/FormatterImpl"
is obtained only if the paths locating the jars pointed by engine.xml are not valid.

The second error which complains about
different Class objects for the type javax/xml/transform/Source used in the signature
resides in the XEP installation which comes with a modified version of the saxon.jar. This jar contains the javax.xml.transform.Source class that is different from the one in our jars.
In order to make it work, we suggest you to make a copy of the XEP installation, remove the existing saxon.jar from its lib directory and use this copy with oXygen.

Regards,
Mircea
Mircea Enachescu
<oXygen> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
kw1
Posts: 2
Joined: Thu May 27, 2010 3:32 pm

Re: XProc and XSL-FO

Post by kw1 »

Thank you very much. Removing the saxon.jar file did the trick.
Post Reply