[xsl] Generating barcode SVG-files

Subject: [xsl] Generating barcode SVG-files
From: Asbjørn Reglund Thorsen <a.r.thorsen@xxxxxxxxxxx>
Date: Mon, 10 Apr 2006 13:31:57 +0200
I have used RenderX's 2to5 interleave barcode generator.
My question is: How can I generate 222222.svg, 123456.svg and 019283.svg files (see my test-XML below) ? I probably need to make a recurcive template ?
I was told that I should use xsl:document. Is xsl:result-document better in any way ?


My test-XML:
---------------------------------
<?xml version="1.0"?>
<doc>
 <barcodes>
   <barcode value="222222" addchecksum="false"/>
   <barcode value="123456" addchecksum="false"/>
   <barcode value="019283" addchecksum="false"/>
 </barcodes>
</doc>

My test-XSL:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:fo="http://www.w3.org/1999/XSL/Format";>
<xsl:import href="2of5i.xsl"/>
<xsl:output method="xml" indent="yes"/>


<xsl:template match="/">
<fo:root font-family="Times" font-size="10pt">
<fo:layout-master-set>
<fo:simple-page-master master-name="barcodes-page">
<fo:region-body margin="0.5in" border="0.25pt solid silver" padding="10pt"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="barcodes-page">
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="barcodes">
<xsl:for-each select="barcode">
<xsl:apply-templates select="." mode="draw"/>
</xsl:for-each>
</xsl:template>
<!-- This template call barcode generator to create SVG representation of 2-of-5 interleave barcode -->
<xsl:result-document href="mytestfile.svg"> <!-- this doesn't work but illustrates how lost I am --> <xsl:template match="barcode" mode="draw">
<fo:block>
<fo:instream-foreign-object content-width="20mm" content-height="20mm">
<xsl:call-template name="barcode-2of5i">
<xsl:with-param name="value" select="@value"/>
<xsl:with-param name="addchecksum" select="@addchecksum"/>
</xsl:call-template>
</fo:instream-foreign-object>
</fo:block>
</xsl:template>
</xsl:result-document>
</xsl:stylesheet>




--
Asbjxrn Thorsen

"HAKONA MATATA" ;-)

Current Thread