<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                version='1.0'>
              


<xsl:template name="header.content">  
  <xsl:param name="pageclass" select="'body'"/>
  <xsl:param name="sequence" select="''"/>
  <xsl:param name="position" select="''"/>
  <xsl:param name="gentext-key" select="''"/>

  <xsl:variable name="candidate">
    <!-- sequence can be odd, even, first, blank -->
    <!-- position can be left, center, right -->
    <xsl:choose>

      <xsl:when test="$sequence = 'odd' and $position = 'left'">
        <fo:retrieve-marker retrieve-class-name="section.head.marker"
                            retrieve-position="first-including-carryover"
                            retrieve-boundary="page"/>
      </xsl:when>


      <xsl:when test="$sequence = 'odd' and $position = 'right'">
        <fo:page-number/>
      </xsl:when>

      <xsl:when test="$sequence = 'even' and $position = 'left'">  
        <fo:page-number/>
      </xsl:when>

      <xsl:when test="$sequence = 'even' and $position = 'right'">
        <xsl:apply-templates select="." mode="titleabbrev.markup"/>
      </xsl:when>

      <xsl:when test="$sequence = 'first' and $position = 'left'">
      </xsl:when>

      <xsl:when test="$sequence = 'first' and $position = 'right'">  
      </xsl:when>

      <xsl:when test="$sequence = 'first' and $position = 'center'"> 
        <xsl:value-of 
               select="ancestor-or-self::book/bookinfo/corpauthor"/> 
      </xsl:when>

      <xsl:when test="$sequence = 'blank' and $position = 'left'">
        <fo:page-number/>
      </xsl:when>

      <xsl:when test="$sequence = 'blank' and $position = 'center'">
        <xsl:text>This page intentionally left blank</xsl:text> 
      </xsl:when>

      <xsl:when test="$sequence = 'blank' and $position = 'right'">
      </xsl:when>

    </xsl:choose>
  </xsl:variable>

    <!-- Does runtime parameter turn off blank page headers? -->
    <xsl:choose>
      <xsl:when test="$sequence='blank' and $headers.on.blank.pages=0"> 
        <!-- no output -->
      </xsl:when>
    <!-- titlepages have no headers -->
      <xsl:when test="$pageclass = 'titlepage'">  
        <!-- no output -->
      </xsl:when>
      <xsl:otherwise>
        <xsl:copy-of select="$candidate"/> 
      </xsl:otherwise>
    </xsl:choose>
 </xsl:template>
 
 </xsl:stylesheet>
 
