<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xt="http://www.jclark.com/xt" version="1.0" extension-element-prefixes="xt">
	<xsl:output method="xml" indent="yes"/>
	<xsl:template match="/*">
		<!-- example for a simple fo file. At the beginning the page layout is set. 
Below fo:root there is always 
- a single fo:layout-master-set which defines one or more page layouts
- an optional fo:declarations,
- and a sequence of one or more fo:page-sequences containing the text and formatting instructions -->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:copy-of select="xfm:xform"/>
	<fo:layout-master-set>
		<!-- fo:layout-master-set defines in its children the page layout: 
       the pagination and layout specifications
       - page-masters: have the role of describing the intended subdivisions 
                       of a page and the geometry of these subdivisions 
       - page-sequence-masters: have the role of describing the sequence 
                                of page-masters that will be used to generate 
                                pages during the formatting of an fo:page-sequence  

  -->
		<!-- layout for the first page -->
		<fo:simple-page-master master-name="first" page-height="{/*/@height}" page-width="18cm" margin-top="1cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
			<fo:region-before extent="3cm"/>
			<fo:region-body margin-top="3cm"/>
			<fo:region-after extent="1.5cm"/>
		</fo:simple-page-master>
		<!-- layout for the other pages -->
		<fo:simple-page-master master-name="rest" height="{/*/@height}" page-width="18cm" margin-top="1cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
			<fo:region-before extent="2.5cm"/>
			<fo:region-body margin-top="2.5cm"/>
			<fo:region-after extent="1.5cm"/>
		</fo:simple-page-master>
		<fo:page-sequence-master master-name="basicPSM">
			<fo:repeatable-page-master-alternatives>
				<fo:conditional-page-master-reference master-name="first" page-position="first"/>
				<fo:conditional-page-master-reference master-name="rest" page-position="rest"/>
				<!-- recommended fallback procedure -->
				<fo:conditional-page-master-reference master-name="rest"/>
			</fo:repeatable-page-master-alternatives>
		</fo:page-sequence-master>
	</fo:layout-master-set>
	<!-- end: defines page layout -->
		<fo:page-sequence master-name="basicPSM">
		<!-- header -->
		<fo:static-content flow-name="xsl-region-before">
			<fo:block text-align="end" font-size="10pt" font-family="serif" line-height="14pt">
        <xsl:value-of select="@title"/> - p. <fo:page-number/>
			</fo:block>
		</fo:static-content>
		<fo:flow flow-name="xsl-region-body">
			<xsl:apply-templates select="h1|h2|link|para|input|button|img|br"/>
		</fo:flow>
		</fo:page-sequence>
	</fo:root>

	</xsl:template>
	
	<!-- *************** h1 *******************-->
	<xsl:template match="h1">
		<!-- defines text title level 1-->
			<fo:block font-size="18pt" font-family="sans-serif" line-height="24pt" space-after.optimum="15pt" background-color="blue" color="white" text-align="center" padding-top="3pt">
        <xsl:value-of select="."/>
      </fo:block>
	</xsl:template>
	
	<!-- *************** h2 *******************-->
	<xsl:template match="h2">
			<!-- defines text title level 2-->
			<fo:block font-size="16pt" font-weight="bold" font-family="sans-serif" line-height="20pt" space-before.optimum="10pt" space-after.optimum="10pt" text-align="start" padding-top="3pt">
        <xsl:value-of select="."/>
      </fo:block>
	</xsl:template>
	<!-- *************** link *******************-->
	<xsl:template match="link">
			<!-- Normal text -->
			<fo:block color="blue" font-size="14pt" space-after.optimum="3pt">
				<fo:basic-link external-destination="{@href}">
					<xsl:value-of select="@text"/>
				</fo:basic-link>
			</fo:block>
	</xsl:template>
	<!-- *************** para|p *******************-->
	<xsl:template match="para|p">
			<!-- Normal text -->
			<fo:block font-size="12pt" font-family="sans-serif" line-height="15pt" space-before.optimum="12pt" space-after.optimum="3pt" text-align="start">
			<xsl:value-of select="."/>
      </fo:block>
	</xsl:template>
	<!-- *************** br *******************-->
	<xsl:template match="br">
			<!-- Normal text -->
			<fo:block font-size="12pt" font-family="sans-serif" line-height="15pt" space-before.optimum="12pt" space-after.optimum="3pt" text-align="start">
			</fo:block>
	</xsl:template>
	<!-- *************** input *******************-->
	<xsl:template match="input" xmlns:xhtml="http://www.w3.org/1999/xhtml">
			<!-- Normal text -->
			<fo:block-container height="4cm">
			<fo:block height="4cm" font-size="12pt" font-family="sans-serif" line-height="15pt" space-after.optimum="3pt" text-align="start">
			<fo:instream-foreign-object><xhtml:form id="test"><xhtml:input name="{@name}"/></xhtml:form></fo:instream-foreign-object>
			</fo:block>
			</fo:block-container>
	</xsl:template>
	<!-- *************** button *******************-->
	<xsl:template match="button" xmlns:xhtml="http://www.w3.org/1999/xhtml">
			<!-- Normal text -->
			<fo:block height="4cm" font-size="12pt" font-family="sans-serif" line-height="15pt" space-after.optimum="3pt" text-align="start">
			<fo:instream-foreign-object><xhtml:form id="test"><xhtml:button name="{@name}"/></xhtml:form></fo:instream-foreign-object>
			</fo:block>
	</xsl:template>
	<!-- *************** img *******************-->
	<xsl:template match="img">
		<fo:block text-align="start">
			<fo:external-graphic src="{@src}"/>
		</fo:block>
	</xsl:template>
	<!-- *************** XForms *******************-->
	<xsl:template match="xfm:xform"/>
	<xsl:template match="xfm:checkbox|xfm:submit|xfm:exclusiveSelect|xfm:inclusiveSelect|xfm:textbox|xfm:trigger|xfm:output">
		<fo:instream-foreign-object>
			<xsl:copy-of select="."/>
		</fo:instream-foreign-object>
	</xsl:template>

</xsl:stylesheet>

