<?xml version="1.0" encoding='iso-8859-1'?>
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format"
  version="1.0"
  >

  <xsl:output  method="xml" indent="yes" />
  <xsl:strip-space elements="*"/>


  <xsl:variable name="base-font">12</xsl:variable>

  <xsl:attribute-set name="head1">
    <xsl:attribute name="font-size"><xsl:value-of select="concat(round($base-font *1.2),'pt')"/></xsl:attribute>
    <xsl:attribute name="font-weight">bold</xsl:attribute>
    <xsl:attribute name="font-family">Helvetica</xsl:attribute>
    <xsl:attribute name="font-style">normal</xsl:attribute>
    <xsl:attribute name="space-before.optimum">18pt</xsl:attribute>
    <xsl:attribute name="space-before.conditionality">discard</xsl:attribute>
    <xsl:attribute name="space-after.optimum">6pt</xsl:attribute>
    <xsl:attribute name="keep-with-next">true</xsl:attribute>
    <xsl:attribute name="page-break-inside">avoid</xsl:attribute>
    <xsl:attribute name="text-align">center</xsl:attribute>
    <xsl:attribute name="padding">3pt</xsl:attribute>
    <xsl:attribute name="background-color">aqua</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="head2">
    <xsl:attribute name="font-size"><xsl:value-of select="concat(round(($base-font *1.2)),'pt')"/></xsl:attribute>
    <xsl:attribute name="font-weight">bold</xsl:attribute>
    <xsl:attribute name="font-family">Helvetica</xsl:attribute>
    <xsl:attribute name="font-style">normal</xsl:attribute>
    <xsl:attribute name="space-before.optimum">18pt</xsl:attribute>
    <xsl:attribute name="space-before.conditionality">discard</xsl:attribute>
    <xsl:attribute name="space-after.optimum">6pt</xsl:attribute>
    <xsl:attribute name="keep-with-next">true</xsl:attribute>
    <xsl:attribute name="page-break-inside">avoid</xsl:attribute>
    <xsl:attribute name="keep-with-next">7</xsl:attribute>
    <xsl:attribute name="text-align">center</xsl:attribute>
    <xsl:attribute name="padding">3pt</xsl:attribute>
    <xsl:attribute name="background-color">#20B2AA</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="border">
    <xsl:attribute name="border-color">blue</xsl:attribute>
    <xsl:attribute name="border-style">solid</xsl:attribute>
    <xsl:attribute name="border-width">1pt</xsl:attribute>
  </xsl:attribute-set>


  <xsl:attribute-set name="font">
    <xsl:attribute name="font-family">Arial</xsl:attribute>
    <xsl:attribute name="font-style">normal</xsl:attribute>
    <xsl:attribute name="font-size"><xsl:value-of select="$base-font-spec"/></xsl:attribute>
  </xsl:attribute-set>



 <xsl:attribute-set name="para">
    <xsl:attribute name="space-before.optimum">
      <xsl:value-of select="$base-font-spec"/> 
    </xsl:attribute>
   <xsl:attribute name="space-after.optimum">
      <xsl:value-of select="$base-font-spec"/> 
    </xsl:attribute>
  </xsl:attribute-set>



  <xsl:template match="simpdoca">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="section">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
    <xsl:apply-templates/>
  </xsl:template>


  <xsl:variable name="base-font-spec"><xsl:value-of select="concat(round($base-font * 1),'pt')"/></xsl:variable>

 
 <!-- Page definitions.  fo:layout-master-set >  /fo:layout-master-set>
Includes template for / -->
 <xsl:include href="pages.xsl"/>
 
<xsl:template match="section/subsect1[not(@id='front-page')]">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>

  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="section/subsect1[@id='front-page']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block     

    background="#E0EeE0" 
    background-image="url('../pig.gif')" 
    background-repeat="no-repeat" 
    background-position="50% 20%"
    break-after="page"><xsl:apply-templates/></fo:block>
</xsl:template>



 <xsl:template match="simpdoca/section/head">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
   <fo:block 
     xsl:use-attribute-sets="head1"
     break-before="page">
      <fo:marker marker-class-name="sect-head" >
        <fo:block><xsl:value-of select="."/> [This is a marker block]</fo:block>
      </fo:marker>
     <xsl:apply-templates/>
   </fo:block>
 </xsl:template>

 <xsl:template match="subsect1[not (@id='front-page' )]/head">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
   <fo:block xsl:use-attribute-sets="head2" keep-with-next.within-page="always">
     <xsl:apply-templates/>
   </fo:block>
 </xsl:template>


 <xsl:template match="subsect1[@id='front-page']/head">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
<!--  padding-before="1in"  -->
   <fo:block 
     font-size="24pt"
     font-weight="bold"
     space-before.optimum="1in"
     space-before.conditionality="retain"
     space-after.optimum="3in"
     text-align="center">
     <xsl:apply-templates/>
   </fo:block>
 </xsl:template>


 <xsl:template match="subsect2">
   <xsl:apply-templates/>
 </xsl:template>

 <xsl:template match="subsect2/head">
     <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block xsl:use-attribute-sets="head2"
    background-color="green"><!-- Notice how this overwrites the head2 value :-) -->
     <xsl:apply-templates/>
   </fo:block>
 </xsl:template>




<xsl:template match="p[@style='banner']">
  <fo:block 
    space-before="1in"
    space-after="1in"
    font-size="16pt"
    font-weight="bold"
    text-align="center"
><xsl:apply-templates/></fo:block>
</xsl:template>



<!-- Default, for any Paragraphs without the style attribute set. -->

  <xsl:template match="p">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
    <fo:block   xsl:use-attribute-sets="para font"><xsl:apply-templates/>
  </fo:block>
  </xsl:template>
<!-- This should not be used. -->


<xsl:template match="p[@style='normal']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block 
    xsl:use-attribute-sets="font para"><xsl:apply-templates/></fo:block>
</xsl:template>

<xsl:template match="p[@style='keep-with-next']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block space-before="24pt"
   xsl:use-attribute-sets="para font"
    keep-with-next.within-page="always"

    ><xsl:apply-templates/></fo:block>
</xsl:template>




<xsl:template match="p[@style='indented']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block 
   xsl:use-attribute-sets="para font"
    start-indent="1in"><xsl:apply-templates/></fo:block>
</xsl:template>

<xsl:template match="p[@indent]">
  <fo:block xsl:use-attribute-sets="para font"
start-indent="{@indent}"><xsl:apply-templates/></fo:block>
</xsl:template>




<xsl:template match="p[@style='space-before']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block xsl:use-attribute-sets="para font"
    space-before.optimum="0.5in"><xsl:apply-templates/></fo:block>
</xsl:template>


<xsl:template match="p[@style='hanging']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block start-indent="1in" 
    text-indent="-1in" 
    xsl:use-attribute-sets="para font"><xsl:apply-templates/></fo:block>
</xsl:template>

<xsl:template match="p[@style='rt-indent']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block 
    start-indent="1in" 
    end-indent="1in" 
    text-indent="-1in" 
    xsl:use-attribute-sets="para font"><xsl:apply-templates/>
</fo:block>
</xsl:template>

<xsl:template match="p[@style='end-align']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block 
    text-align="end" 
    padding-end="6pt" xsl:use-attribute-sets="para font"><xsl:apply-templates/>
</fo:block>
</xsl:template>

<xsl:template match="p[@style='centred']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block text-align="center" xsl:use-attribute-sets="para font"><xsl:apply-templates/></fo:block>
</xsl:template>


<xsl:template match="p[@style='justified']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block start-indent="0.5in" 
    end-indent="0.5in" 
    text-align="justify" 
    xsl:use-attribute-sets="para font"><xsl:apply-templates/></fo:block>
</xsl:template>

<xsl:template match="p[@style='col-justified']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block start-indent="0.1in" 
    text-align="justify" 
    xsl:use-attribute-sets="para font"><xsl:apply-templates/></fo:block>
</xsl:template>





<xsl:template match="p[@style='padding']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block 
    xsl:use-attribute-sets="para border font" 
    padding="12pt"  	   
    ><xsl:apply-templates/></fo:block>
	
</xsl:template>

<xsl:template match="p[@style='indent']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block 
    border-style="solid"
    border-color="white"
    border-start-width="1in"  	
    border-end-width="1in"
    text-align="justify" 

    ><xsl:apply-templates/></fo:block>
</xsl:template>

<xsl:template match="p[@style='bal-indent']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block 
    start-indent="1in"
    end-indent="1in"
    xsl:use-attribute-sets="para font"
    ><xsl:apply-templates/></fo:block>
</xsl:template>




<xsl:template match="p[@style='pre1']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block 
   space-before.optimum="{concat(round($base-font * 2),'pt')}"
   padding-start="0.5in"  	
   padding-end="0.5in"
    wrap-option="no-wrap"
    white-space-collapse="false"
    linefeed-treatment="preserve"

   font-size="{$base-font-spec}"
    ><xsl:apply-templates/></fo:block>
</xsl:template>


<xsl:template match="p[@style='pre2']">
  <fo:block
   white-space="pre"
  font-size="{$base-font-spec}"
    ><xsl:apply-templates/></fo:block>
</xsl:template>

<xsl:template match="p[@style='line-height']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block
    line-height="2"
    xsl:use-attribute-sets="para font">
    <xsl:apply-templates/>
  </fo:block>

 <fo:block>
    <fo:inline-container>
      <fo:block 
        xsl:use-attribute-sets="para font"
        text-align="start">
        <fo:external-graphic  src="../pig.gif" />  <fo:inline vertical-align="top">some text which may well wrap around the image some text which may well wrap around the image some text which may well wrap around the image some text which may well wrap around the image</fo:inline>
      </fo:block>
     
    </fo:inline-container>
  </fo:block>

</xsl:template>






<xsl:template match="style[@style='bold']|b">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:inline
    font-weight="bold"><xsl:apply-templates/></fo:inline>
</xsl:template>


<xsl:template match="style[@style='italic']">
  <xsl:if test="@id">
       <fo:inline id="{@id}"/>
    </xsl:if>
  <fo:inline
    font-style="italic"><xsl:apply-templates/></fo:inline>
</xsl:template>

<xsl:template match="style[@style='times']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:inline
    font-family="Times" 
    font-size="16pt"
    font-weight="bold"><xsl:apply-templates/></fo:inline>
</xsl:template>

<xsl:template match="style[@style='helvetica']">
  <xsl:if test="@id">
    <fo:inline id="{@id}"/>
    </xsl:if>
  <fo:inline
    font-family="Helvetica"><xsl:apply-templates/></fo:inline>
</xsl:template>

<xsl:template match="style[@style='courier']">
  <xsl:if test="@id">
    <fo:inline id="{@id}"/>
    </xsl:if>
  <fo:inline
    font-family="Courier"><xsl:apply-templates/></fo:inline>
</xsl:template>

<xsl:template match="style[@style='arial']">
  <xsl:if test="@id">
    <fo:inline id="{@id}"/>
    </xsl:if>
  <fo:inline
    font-family="Arial"><xsl:apply-templates/></fo:inline>
</xsl:template>



<xsl:template match="style[@style='serif']">
  <xsl:if test="@id">
    <fo:inline id="{@id}"/>
    </xsl:if>
  <fo:inline
    font-family="serif"><xsl:apply-templates/></fo:inline>
</xsl:template>


<xsl:template match="style[@style='mono']">
  <xsl:if test="@id">
    <fo:inline id="{@id}"/>
    </xsl:if>
  <fo:inline
    font-family="monospace"><xsl:apply-templates/></fo:inline>
</xsl:template>





<xsl:template match="style[@style='red']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:inline
    color="red"><xsl:apply-templates/></fo:inline>
</xsl:template>

<xsl:template match="style[@style='underline']">
  <xsl:if test="@id">
    <fo:inline id="{@id}"/>
    </xsl:if>
  <fo:inline
    text-decoration="underline"><xsl:apply-templates/></fo:inline>
</xsl:template>


<xsl:template match="style[@style='overline']">
  <xsl:if test="@id">
    <fo:inline id="{@id}"/>
    </xsl:if>
  <fo:inline line-height="18pt" 
    text-decoration="overline"><xsl:apply-templates/></fo:inline>
</xsl:template>






<xsl:template match="style[@style='strikethrough']">
  <xsl:if test="@id">
    <fo:inline id="{@id}"/>
    </xsl:if>
  <fo:inline
    text-decoration="line-through"><xsl:apply-templates/></fo:inline>
</xsl:template>



<xsl:template match="style[@style='big']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <xsl:variable name="big"><xsl:value-of select="concat(($base-font * 2),'pt')"/></xsl:variable>
  <fo:inline
    font-size="{$big}"><xsl:apply-templates/></fo:inline>
</xsl:template>

<xsl:template match="style[@style='super']">
  <xsl:if test="@id">
      <fo:inline id="{@id}"/>
    </xsl:if>
  <fo:inline
    baseline-shift="10%"><xsl:apply-templates/></fo:inline>
</xsl:template>

<xsl:template match="style[@style='int-link']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:inline background-color="blue"><fo:basic-link
    internal-destination="{@idref}">Page 
    <fo:page-number-citation ref-id="intro"/>
  </fo:basic-link></fo:inline>
</xsl:template>


<xsl:template match="leaders">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block start-indent="0.5in" end-indent="0.5in" text-align-last="justify">
1. Introduction. <fo:leader leader-pattern="dots"/> Page
  <fo:page-number-citation ref-id="intro"/>
</fo:block>
</xsl:template>







<!-- lists -->

<xsl:template match="list[@style='plain']|list">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:list-block 
    provisional-distance-between-starts="15mm"
    provisional-label-separation="5mm">
    <xsl:apply-templates/>
  </fo:list-block>
</xsl:template>


<xsl:template match="litem[@style='plain']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:list-item>
    <fo:list-item-label end-indent="label-end()">
      <fo:block>&#x2022;</fo:block>
    </fo:list-item-label>
    <fo:list-item-body start-indent="body-start()" ><fo:block><xsl:apply-templates/></fo:block></fo:list-item-body>
  </fo:list-item>
</xsl:template>

<xsl:template match="litem[@style='numbered']">
  <fo:list-item>
    <fo:list-item-label end-indent="label-end()">
      <fo:block><xsl:number level="multiple" count="litem" from="list"/></fo:block>
    </fo:list-item-label>
    <fo:list-item-body start-indent="body-start()">
          <fo:block><xsl:apply-templates/></fo:block>
    </fo:list-item-body>
  </fo:list-item>
</xsl:template>



<xsl:template match="img">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block text-align="center"><fo:block>The surrounding block, not the fo:external graphic, has text-align="center"</fo:block>
  <fo:external-graphic
    content-height="30%"
    content-width="30%"
    src="{@src}"/>
  </fo:block>




</xsl:template>

<xsl:template match="figure">
  <fo:block  
    padding-before="1cm" 
    padding-after="1cm"><xsl:apply-templates/></fo:block>
</xsl:template>

<xsl:template match="img2">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block text-align="start">
  <fo:external-graphic  src="../{@src}"/>
  </fo:block>
</xsl:template>

<xsl:template match="caption">
  <fo:block 
    space-before="3pt" 
    text-align="center"
    start-indent="10mm" end-indent="10mm">
    <xsl:apply-templates/>
  </fo:block>
</xsl:template>


<xsl:template match="rule">
 <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block text-align="center">
  <fo:leader
    leader-pattern="rule"
    color ="green"
    rule-style="groove"
    rule-thickness="{@thickness}"
    leader-length.optimum="{@length}"
    />
  </fo:block>
</xsl:template>



<!--  -->
<!-- Tables, not quite in all their glory -->
<!--  -->

<xsl:template match="table[@style='plain']">
  <xsl:if test="@id">
      <xsl:call-template name="id"/>
    </xsl:if>
  <fo:block space-before="12pt">
    <fo:table 
      table-layout="fixed"
      border-spacing="3pt 6pt" 
      border-collapse="separate" 
      border="1pt double blue" 
      padding="3pt"  
      > 
    <xsl:if test="tablebody/colheads">
      <xsl:apply-templates select="tablebody/colheads"/>
    </xsl:if>
    <xsl:apply-templates/>
  </fo:table>
</fo:block>
</xsl:template>

<xsl:template match="tablebody">
  <fo:table-body><xsl:apply-templates select="row"/></fo:table-body>
</xsl:template>

<xsl:template match="colheads">
  <fo:table-header>
    <fo:table-row><xsl:apply-templates/></fo:table-row>
  </fo:table-header>
</xsl:template>

<xsl:template match="table[@style='plain']/tablebody/colheads/chead">
  <xsl:choose>
  <xsl:when test="@colspan">
 <fo:table-cell
   number-columns-spanned="{@colspan}"
    vertical-align="middle"
    text-align="center"
    border="0.5pt solid black"
    padding="4pt">
    <fo:block><xsl:apply-templates/></fo:block>
  </fo:table-cell>
  </xsl:when>
  <xsl:otherwise>
  <fo:table-cell
    vertical-align="middle"
    text-align="center"
    border="0.5pt solid black"
    padding="4pt">
    <fo:block><xsl:apply-templates/></fo:block>
  </fo:table-cell>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="row">
  <fo:table-row>
    <xsl:apply-templates/>
  </fo:table-row>
</xsl:template>


<xsl:template match="table[@style='plain']/tablebody/row/di">
  <fo:table-cell
    vertical-align="middle"
    text-align="center"
    border="0.5pt solid black"
    padding="4pt">
    <fo:block><xsl:apply-templates/></fo:block>
  </fo:table-cell>
</xsl:template>

<!-- Variable width columns -->
<xsl:template match="table[@style='var-width']">
 <fo:table-and-caption start-indent="0.2in">
   <fo:table-caption>
     <fo:block>This table has a caption. See note 
     <fo:footnote> 
     <fo:inline 
       vertical-align="super" 
       font-size="75%">(1)</fo:inline>
     <fo:footnote-body>
       <fo:list-block 
         border-before-style="solid"
         border-before-color="black"
         border-before-width="1pt"
         padding-before="2pt"
         provisional-distance-between-starts="15pt" 
         provisional-label-separation="2pt" 
         space-before.optimum="6pt" 
         space-before.conditionality="discard" 
         line-height="1.2" 
         font-size="10pt" 
         font-family="Times">
         <fo:list-item>
         <fo:list-item-label>
           <fo:block>
             <fo:inline
               vertical-align="super" 
               font-size="75%">(1)
           </fo:inline>
         </fo:block>
       </fo:list-item-label>
       <fo:list-item-body start-indent="body-start()">
       <fo:block>This is achieved using the outer wrapper fo:table-and-caption. It also permits me to demonstrate the mess that has to be made of a simple table, simply to get in a footnote. Made far worse when its formatted as a list, to permit the seperation of note number from note content. I do have to admit though, that it looks better when laid out this way. I'd suggest that footnotes go into a named template, with parameters of Note number and content. By the way, the notes seperator is simply a border-before on the fo:list-block. Then add some padding-before to seperate it from the line from the note content. With XEP its not necessary to add the rule, with Antenna House it is.</fo:block>
     </fo:list-item-body>
   </fo:list-item>
   </fo:list-block>
     </fo:footnote-body>
   </fo:footnote>
   </fo:block>
 </fo:table-caption>
   <fo:table>
    <fo:table-column column-number="1"  column-width="0.5in"/>
    <fo:table-column column-number="2"  column-width="1in"/>
    <fo:table-column column-number="3"  column-width="3in"/>
    <fo:table-column column-number="4"  column-width="0.7in"/>
   <fo:table-column column-number="5"  column-width="0.5in"/>
    <fo:table-body>
  <fo:table-row>
      <fo:table-cell border="0.5pt solid black" padding="2pt">
       <fo:block>C1</fo:block>
      </fo:table-cell>

      <fo:table-cell border="0.5pt solid black" padding="2pt">
       <fo:block>C 2</fo:block></fo:table-cell>
      <fo:table-cell border="0.5pt solid black" padding="2pt">
       <fo:block> Column 3, with room to say that the fo:table-column is used to specify each column by column-number and column-width, after fo:table and before fo:table-body.</fo:block></fo:table-cell>
      <fo:table-cell border="0.5pt solid black" padding="2pt">
       <fo:block>C4</fo:block></fo:table-cell>
    <fo:table-cell border="0.5pt solid black" padding="2pt">
       <fo:block>C5</fo:block></fo:table-cell>
     </fo:table-row>

    </fo:table-body>
  </fo:table>
  </fo:table-and-caption>
 </xsl:template>
                    
 <xsl:template match="idx">
 <fo:block 
   start-indent="0.5in" 
   end-indent="0.5in" 
   font-size="{$base-font-spec}"
   text-align-last="justify">
   <fo:inline font-weight="bold">Item</fo:inline> <fo:leader leader-pattern="dots"/><fo:inline font-weight="bold">Page</fo:inline>
</fo:block>
   <xsl:apply-templates/>
 </xsl:template>

 <xsl:template match="idx/item">
 <fo:block 
   start-indent="0.5in" 
   end-indent="0.5in" 
   font-size="{$base-font-spec}"
   text-align-last="justify">
   <xsl:apply-templates/>
 <fo:leader leader-pattern="dots"/><fo:basic-link
 internal-destination="{@idref}"> <fo:page-number-citation color="blue" ref-id="{@idref}"/></fo:basic-link>
</fo:block>
 </xsl:template>
   

 <xsl:template name="id">
   <fo:block id="{@id}"/>
 </xsl:template>


<xsl:template match="*">
  <fo:block
   background-color="red">
 ***************** Found <xsl:value-of select="name()"/> ***************
  <xsl:message terminate="yes">Found unstyled element &lt;<xsl:value-of select="name()"/>&gt;,@<xsl:value-of select="@*"/> aborting.</xsl:message>
</fo:block>
</xsl:template>




</xsl:stylesheet>

