Re: Krysalis Barcode and Saxon

Jeremias Maerki <[email protected]> Wed, 10 Sep 2003 22:34:33 +0200
Newsgroups gmane.comp.krysalis.user
Message-ID <[email protected]>
Hello Jan

On 10.09.2003 09:58:39 Jan Kohnert wrote:
> I ve tried several things to get the Saxon run with Krysalis Barcode.
> But I alwys got a message saying: "There is no Java method that is a unique
> best match".
> 
> I also looked into the BarcodeExt.java file but found only one general
> function having two arguments. I m wondering why it is saying thomething
> about a "unique best match" when there is only one general function at all
> (which is called with exactly two arguments in your example file which I
> used).
> 
> I looked into the "XSLT 2nd Edition" book from Michael Kay and on page 776
> (bottom) I found a note saying that Saxon does only look for functions that
> have the right name and the right number of arguments, but if it finds more
> than one, it reports an error, rather than trying to finde the one that is
> the best fit to the arguments supplied.

Unfortunately, I don't have Michael Kay's book. All I have on Saxon
extensibility is the link I gave you in the last email. I've also had a
quick look at the sources, especially the sql package which serves as an
example for Saxon extensions. But this didn't help a lot, yet, to
understand what really would be needed to build a barcode extension for
Saxon. I'll have a couple of hours on Friday to look into this. Looks
more complicated than I first thought.

> Are there more general functions elsewehre in the code?

Not really.

> I also wondered why the BarcodeExt.java file is special for Xalan. What
> steps have to be taken to convert it for Saxon?

Well, BarcodeExt is constructed after the instructions from Xalan-J to
build an extension. Saxon obviously requires a few more things (an
ExtensionElementFactory, implementation of the StyleElement interface
etc.). See http://saxon.sourceforge.net/saxon6.5.3/extensibility.html.

In the end it looks like some completely different code is needed. But
ideas can still be taken from BarcodeExt. I'll look into it.

> I also looked into the lates code on CVS, but did'nt realy got the point.
> How do I use the latest extentions for FOP? Since I m generating FO with FOP
> it does not matter for me in wich step the SVG barcode is generated. So
> having it generated by FOP is fine for me. But how do I get Krysalis Barcode
> work with FOP?

Too bad, I haven't written the documentation to point you to, yet, so
let's see:

You got the sources, right? Create a text file called
build-local.properties and place it in the same directory as Krysalis
Barcode's build.xml (the root dir). Add a single line to that text file:

fop-0.20.5.home=D:/FOP/releases/fop-0.20.5

Adjust that directory as necessary. Make sure you've got a compiled or
binary FOP 0.20.5 in that directory (build.xml needs build\fop.jar and
lib\batik.jar). Now, run the Barcode build and you should get 
build\krysalis-barcode-fop-ext-0.20.5-complete.jar among others. The jar
contains both the whole Barcode package as well as the FOP extension.

Add that JAR to the classpath under which FOP is run. The JAR will
automatically register itself with FOP (through a file in META-INF). To
create a barcode you can use an fo:instream-foreign-object for the
Barcode XML:

Example:
  <fo:instream-foreign-object>
    <bc:barcode xmlns:bc="http://www.krysalis.org/barcode/ns" msg="4194586705506+07">
      <bc:ean-13>
        <bc:human-readable>top</bc:human-readable>
      </bc:ean-13>
    </bc:barcode>
  </fo:instream-foreign-object>

An example file can be found in examples/xsl-fo/fop-extension-demo.fo.

I hope that works. I'd be grateful for any feedback as you're probably
my first victim to try the new FOP extension.

Jeremias Maerki



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf