Creating barcodes with XSL
13:44, 4 Oct 2000 UTC | Edd Dumbill

Continuing with their mission to promote XSL-FOs, RenderX have created an XSL stylesheet to create barcodes, and made it available as an online demo.

Using several hundred lines of XSLT, the stylesheet does all the requisite calculations to generate EAN and UPC barcodes, including the generation of the check digit:

The stylesheet handles EAN codes (8-digit and 13-digit) and UPC codes (versions A and E). It provides for checksum calculation (including the trickiest UPC E case), and builds a complete pattern with numbers written at the bottom.
The stylesheet does more than just creating a sequence of bars: it also chooses the most traditional format for each type of code. There are subtle differences between EAN and UPC concerning digit grouping, bar lengths etc; all these are taken into account in the stylesheet.

The barcode generator is available as an online demo. The generous chaps at RenderX recommend taking "a bottle/can of your favourite drink out of the fridge" and using the generator to create an identical barcode to the one on the drink.

The generator itself uses an XSLT processor and RenderX's XEP XSL-FO to PDF converter.

Bug reports and empty bottles should be sent to the author, Nikolai Grigoriev.

Re: Creating barcodes with XSL (Ed Syrett - 14:53, 18 Jan 2002)

It's slow!!!! ... and I'm not really surprised because it's a big bit of XSL to parse and run, and because of that I don't think we shall use it against the fast label printers that we will be using. Instead, I think we will be using a dedicated barcode printing app. Shame really....

xmlhack: developer news from the XML community

Front page | Search | Find XML jobs

Related categories