Instructions for the SAXON extension
Introduction
This page describes how to generate barcodes in SVG format within an XSLT stylesheet that is processed with the SAXON XSLT Processor from Michael Kay.
Using the barcode extension for SAXON
This package contains an extension for SAXON for generating barcodes in SVG format.
To make to barcode extension available in your XSLT stylesheets, do the following:
- Add barcode4j.jar to the classpath.
- Add the following namespace declaration to the root element of your XSLT stylesheet: xmlns:barcode="http://barcode4j.krysalis.org/org.krysalis.barcode4j.saxon.BarcodeExtensionElementFactory"
- Add the barcode namespace prefix to the extension element prefixes: extension-element-prefixes="barcode"
Here's an example:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:barcode=
"http://barcode4j.krysalis.org/org.krysalis.barcode4j.saxon.BarcodeExtensionElementFactory"
extension-element-prefixes="barcode">
To generate a barcode use simply use the "barcode" element in your template as indicated in the example:
<fo:block>
<fo:instream-foreign-object>
<barcode:barcode message="{msg}">
<barcode:code128>
<barcode:height>8mm</barcode:height>
</barcode:code128>
</barcode:barcode>
</fo:instream-foreign-object>
</fo:block>
The XML syntax used within the barcode element is the Barcode XML.
by Jeremias Märki


