XSLT barcode generator from RenderX

3.7k Views Asked by At

Any has any idea why the 'code128-svg.xsl' contains some nonsense? Can anyone teach me how to use download the necessary files from RenderX Code 128? I have downloaded those code128.xsl, code128-svg.xsl, testdata.xml and test-barcodes-fo.xsl to test on local but failed...

I test it by open the xml in IE, I add

<?xml-stylesheet type="text/xsl" href="testbarcode.xsl"?>

at the top of the xml...

The output is:

This document contains several examples of Code 128 barcodes. A special stylesheet interprets data string (special character escaped by '%') and encodes it using Code 128 into a sequence of bar states. Those barstates are drawn in SVG. On the left, final barcodes are shown; on the right, barcode generator stylesheet input parameters and description are listed. Please refer to explanations inside of the code128.xsl stylesheet for more information about the stylesheet usage. Barcode representing Supplier Part Number 'BK500EI' found on APC UPS unit. (first '1P' stands for 'Supplier Part Number'). Whole barcode coded using 'A' code subset. Barcode representing Serial Number 'CB500J1C3Y' found on SonyEricsson T68i mobile phone. (first 'S' stands for 'Serial'). Whole barcode coded using 'B' code subset. Barcode representing number '067023611120229212' found on Nokia 3210 battery. Whole barcode coded using 'C' code subset. Composite barcode. Initially code subset set to 'B', but it's switched to 'C' when coding numerical data to improve barcode information density. UCC/EAN Barcode, first data character is "function code one" (%FNC1%) followed by "Application Identifier" and the data itself. This type of barcode is usually coded using 'C' code subset.

1

There are 1 best solutions below

1
On

The stylesheets creates SVG and the main template expects to be called so you have to write some wrapper code in XSLT to create XHTML for instance to contain the various SVG images with the bar codes. I have put together a sample at http://home.arcor.de/martin.honnen/xslt/testdataBarCode2014123101.xml which renders fine for me with current versions of Firefox and IE on Windows 8.1.

The file has <?xml-stylesheet type="text/xsl" href="test2014123101.xml"?> and that stylesheet does

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  xmlns="http://www.w3.org/1999/xhtml">

<xsl:import href="code128.xsl.xml"/>

<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">
  <html lang="en">
    <head>
      <title>SVG bar code examples</title>
    </head>
    <body>
      <h1>SVG bar code examples</h1>
      <ul>
        <xsl:apply-templates select="//barcode"/>
      </ul>
    </body>
  </html>
</xsl:template>

<xsl:template match="barcode">
  <li>
      <xsl:call-template name="barcode-code128">
        <xsl:with-param name="value" select="@value"/>
        <xsl:with-param name="string" select="@string"/>
        <xsl:with-param name="print-text" select="$print-text"/>
        <xsl:with-param name="subset" select="@subset"/>
        <xsl:with-param name="makeUCC" select="$makeUCC"/>
        <xsl:with-param name="module" select="$module"/>
        <xsl:with-param name="height" select="$height"/>
        <xsl:with-param name="quiet-horizontal" select="$quiet-horizontal"/>
        <xsl:with-param name="quiet-vertical" select="$quiet-vertical"/>
        <xsl:with-param name="font-family" select="$font-family"/>
        <xsl:with-param name="font-height" select="$font-height"/>
      </xsl:call-template>
   </li>
</xsl:template>

</xsl:stylesheet>