<?xml version="1.0"?>
<!-- ========================================================= -->
<!--                                                           -->
<!-- (c) 2003, RenderX.                                        -->
<!--                                                           -->
<!-- Authors: Alexander Peshkov <peshkov@renderx.com>          -->
<!--                                                           -->
<!-- ========================================================= -->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:fo="http://www.w3.org/1999/XSL/Format">
    
<!-- ========================================================= -->
<!-- This stylesheet is aimed to test 3-of-9 barcode generator -->
<!-- implemented in XSLT (3of9.xsl). Stylesheet creates XSL FO -->
<!-- document based on an appropriate XML input, for every     -->
<!-- barcode entry in this XML it calls named template         -->
<!-- to create SVG representation of 3-of-9 barcode.           -->
<!--                                                           -->
<!-- For more details please refer to the documentation found  -->
<!-- inside of the 3of9.xsl stylesheet.                       -->
<!--                                                           -->
<!-- ========================================================= -->

    <!-- Import barcode generator templates -->
    <xsl:import href="../3of9.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="doc">
      <fo:block text-align="center" font-family="Helvetica" font-size="16pt" font-weight="bold">
        <xsl:value-of select="@title"/>
      </fo:block>
      <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="para">
      <fo:block text-indent="16pt"><xsl:apply-templates/></fo:block>
    </xsl:template>

    <xsl:template match="barcodes">
      <fo:table space-before="16pt">
        <fo:table-column column-width="110mm" column-number="1"/>
        <fo:table-column column-width="proportional-column-width(1)" column-number="2"/>
        <fo:table-body>
          <xsl:for-each select="barcode">
            <fo:table-row>
             <fo:table-cell column-number="1" border="thin solid black" text-align="center">
               <xsl:apply-templates select="." mode="draw"/>
             </fo:table-cell>
             <fo:table-cell column-number="2" border="thin solid black" padding="6pt">
               <xsl:apply-templates select="." mode="describe"/>
             </fo:table-cell>
            </fo:table-row>
          </xsl:for-each>
        </fo:table-body>
      </fo:table>
    </xsl:template>

	<!-- This template call barcode generator to create SVG representation of 3-of-9 barcode -->
	<xsl:template match="barcode" mode="draw">
	  <fo:block>
	    <fo:instream-foreign-object content-width="100%" content-height="100%">
	      <xsl:call-template name="barcode-3of9">
	        <xsl:with-param name="value" select="@value"/>
	        <xsl:with-param name="addchecksum" select="@addchecksum"/>
	        <xsl:with-param name="print-text" select="@print-text"/>
	      </xsl:call-template>
	    </fo:instream-foreign-object>
	  </fo:block>
	</xsl:template>

	<xsl:template match="barcode" mode="describe">
	  <fo:block font-weight="bold">Barcode value: <xsl:value-of select="@value"/></fo:block>
	  <fo:block font-weight="bold">Generate checksum: <xsl:value-of select="@addchecksum"/></fo:block>
	  <fo:block space-before="6pt">
	    <xsl:value-of select="description"/>
	  </fo:block>
	</xsl:template>


</xsl:stylesheet>