<?xml version="1.0"?>
<!-- ============================================================= -->
<!--                                                               -->
<!-- (c) 2003, RenderX.                                            -->
<!--                                                               -->
<!-- Author: 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 Australia Post 4-state       -->
<!-- barcode generator implemented in XSLT (4state-au.xsl).        -->
<!-- Stylesheet creates XSL FO document based on appropriate XML   -->
<!-- input, for every barcode entry in this XML it calls named     -->
<!-- template to create SVG representation of 4-state barcode.     -->
<!--                                                               -->
<!-- For more details please refer to the documentation found      -->
<!-- inside the 4state-au.xsl stylesheet.                          -->
<!--                                                               -->
<!-- ============================================================= -->

    <!-- Import barcode generator templates -->
    <xsl:import href="../4state-au.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="90mm" 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">
               <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 Australia Post 4-state barcode -->
	<xsl:template match="barcode" mode="draw">
	  <fo:block>
	    <fo:instream-foreign-object content-width="100%" content-height="100%">
	      <xsl:call-template name="barcode-4state-au">
		    <xsl:with-param name="FCC" select="@FCC"/>
		    <xsl:with-param name="DPID" select="@DPID"/>
		    <xsl:with-param name="CI" select="@CI"/>
		    <xsl:with-param name="CIencoding" select="@CIencoding"/>	  
	      </xsl:call-template>
	    </fo:instream-foreign-object>
	  </fo:block>
	</xsl:template>

	<xsl:template match="barcode" mode="describe">
	  <fo:block font-weight="bold">FCC=<xsl:value-of select="@FCC"/></fo:block>
	  <fo:block font-weight="bold">DPID=<xsl:value-of select="@DPID"/></fo:block>
	  <xsl:if test="@CI!=''"><fo:block font-weight="bold">CI=<xsl:value-of select="@CI"/></fo:block></xsl:if>
	  <xsl:if test="@CIencoding!=''"><fo:block font-weight="bold">CIencoding=<xsl:value-of select="@CIencoding"/></fo:block></xsl:if>
	  <fo:block space-before="6pt">
	    <xsl:value-of select="description"/>
	  </fo:block>
	</xsl:template>
	
</xsl:stylesheet>