barcode4j, Saxon

Here should go questions about transforming XML with XSLT and FOP.
Jesper Tverskov
Posts: 7
Joined: Fri Sep 14, 2012 6:03 pm

barcode4j, Saxon

Post by Jesper Tverskov »

Hi

I'm trying to transform to pdf, using Saxon-EE 9.4.0.3, in newest Oxygen XML Editor and build-in FOP.

I have an XSLT stylesheet and it transforms nicely to PDF except for the following barcode:

<fo:instream-foreign-object> <barcode:barcode xmlns:barcode="http://barcode4j.krysalis.org/ns"
.....etc...

Do I have to install some plugin or specify some Saxon extension to get the barcode working?

Cheers,
Jesper Tverskov
Jesper Tverskov
Posts: 7
Joined: Fri Sep 14, 2012 6:03 pm

Re: barcode4j, Saxon

Post by Jesper Tverskov »

Hi again

I read at the barcode4j website that Saxon is no longer supported but that I can make use of the FOP extension instead.

So that is now my question:

How can I in OXYGEN tell FOP to use the barcode4j extension?

Cheers
Jesper Tverskov
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: barcode4j, Saxon

Post by sorin_ristache »

Hi,

Yes, Saxon is no longer supported, but you can configure Barcode4j as Xalan extension. Oxygen includes Xalan 2.7.1.

The Barcode4j instructions for running it as an extension for Apache FOP 0.93 or later (Oxygen comes with Apache FOP 1.0) only say that it is enough to add either barcode4j.jar + barcode4j-fop-ext.jar or barcode4j-fop-ext-complete.jar to the classpath. I tried that (which in the simplest way amounts to simply dropping the jar(s) in [Oxygen-install-dir]/lib and restarting Oxygen) but I did not get a barcode in the PDF output by running the samples from the Barcode4j distribution :( I am not sure yet why it does not work, I will look again. However I am sure the jar is in the classpath when I apply Apache FOP to the sample FO file from the Barcode4j distribution package.


Regards,
Sorin
Jesper Tverskov
Posts: 7
Joined: Fri Sep 14, 2012 6:03 pm

Re: barcode4j, Saxon

Post by Jesper Tverskov »

Thanks for the help.

But it is simly too far out to start using old Xalan 2.7.1., I normaly play around with Saxon's XSLT 2.0 processor and soon XSLT 3.0.

I will go to the Saxon Help Forum and ask what to do, or maybe there is some other Barcode modul, I can use.

Cheers
Jesper Tverskov
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: barcode4j, Saxon

Post by sorin_ristache »

Hi,

There is no Saxon extension included in the Barcode4j package so you cannot use Barcode4j as Saxon extension unless you write this extension in Java yourself. I would go the way of using it as an Apache FOP extension by adding either barcode4j.jar + barcode4j-fop-ext.jar or barcode4j-fop-ext-complete.jar to the classpath of Apache FOP. I am not sure why Apache FOP does not pick it up from the classpath (at least that's what happened in my tests) but the Barcode4j documentation says it should work as Apache FOP extension.


Regards,
Sorin
Jesper Tverskov
Posts: 7
Joined: Fri Sep 14, 2012 6:03 pm

Re: barcode4j, Saxon

Post by Jesper Tverskov »

Hi again

I have tried Sorin's suggestion of adding "either barcode4j.jar + barcode4j-fop-ext.jar or barcode4j-fop-ext-complete.jar" to the classpath of Apache FOP (I dumped the files as Sorin suggests). But also no result.

I have it all working at the command line. I can use Saxon to do the XSLT transformation, and then use FOP and the barcode module to transform from xslfo to pdf, and it also works when using FOP and Xalan as part of FOP.

But I must say it would make me very happy if we could also get this working from inside Oxygyn.

Cheers,
Jesper
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: barcode4j, Saxon

Post by sorin_ristache »

Hello,

I figured out why dropping the barcode4j-fop-ext-complete.jar file in the lib directory is not enough :) You have to define an external FO processor in Option -> Preferences based on the jar files necessary for running Apache FOP (fop.jar, avalon-framework-4.2.0.jar, batik-all-1.7.jar, commons-io-1.3.1.jar, etc) because the built-in FOP processor has in the classpath only a strict set of jar files that come with the Oxygen installation. After you create the new FO processor based on the Apache FOP jar files (you can use the jar files from [Oxygen-install-dir]/lib) and the barcode4j-fop-ext-complete.jar file, you have to select the new FO processor on the FO Processor tab of the dialog box for editing the transformation.


Regards,
Sorin
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: barcode4j, Saxon

Post by sorin_ristache »

Hi Jesper,

Starting with version 14.1 which we released just two days ago the built-in Apache FOP processor loads any jar file from directory [Oxygen-install-dir]/lib/fop. So you should just create a sub-directory called fop inside [Oxygen-install-dir]/lib, drop the barcode4j-fop-ext-complete.jar there and apply the built-in transform FO PDF to your FO file which includes the calls to the Barcode4j extension. No need for an external processor in the FO Preferences. The FO PDF transform is the first one in the list of all transforms and has a small yellow key icon when the currently edited file is a FO file.


Regards,
Sorin
Jesper Tverskov
Posts: 7
Joined: Fri Sep 14, 2012 6:03 pm

Re: barcode4j, Saxon

Post by Jesper Tverskov »

Yeeeees! It is working.

Thanks Sorin + oXygen

Cheers
Jesper Tverskov
http://www.xmlplease.com
Post Reply