cv_print.xsl
author Fabien Ninoles <fabien@tzone.org>
Mon, 14 Sep 2015 11:32:00 -0400
branchstyles
changeset 20 78ac9176f4ef
parent 13 a1ec4d6963d7
child 23 8445a48b1679
permissions -rw-r--r--
Merge

<?xml version="1.0"?>
<xsl:stylesheet version="1.1"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xt="http://www.jclark.com/xt"
  extension-element-prefixes="xt" 
  xmlns="http://www.w3.org/1999/XSL/Format">

<xsl:import href="common.xsl"/>
<xsl:import href="print.xsl"/>

  <xsl:output method="xml"
        indent="yes"/>

<xsl:template name="gentext">
  <xsl:param name="string"/>
  <xsl:variable name="uri">
    <xsl:text>cv_str.</xsl:text>
    <xsl:value-of select="/cv/@lang"/>
    <xsl:text>.xml</xsl:text>
  </xsl:variable>
  <!-- xsl:message>Looking for <xsl:value-of select="$string"/> in <xsl:value-of select="$uri"/>.</xsl:message -->
  <xsl:value-of select="document($uri)//*[@name=$string]"/>
</xsl:template>

<xsl:param name="cv-uri"/>
<xsl:param name="date"/>
<xsl:attribute-set name="section-title-font" use-attribute-sets="verylarge-title-font">
  <xsl:attribute name="font-size">12pt</xsl:attribute>
  <xsl:attribute name="font-weight">bold</xsl:attribute>
  <xsl:attribute name="space-after">4pt</xsl:attribute>
  <xsl:attribute name="text-decoration">underline</xsl:attribute>
  <xsl:attribute name="score-spaces">true</xsl:attribute>
  <xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="knowledge-title-font" use-attribute-sets="large-title-font">
  <xsl:attribute name="font-size">12pt</xsl:attribute>
  <xsl:attribute name="font-weight">bold</xsl:attribute>
  <xsl:attribute name="space-after">4pt</xsl:attribute>
  <xsl:attribute name="space-before">4pt</xsl:attribute>
  <xsl:attribute name="font-variant">small-caps</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="work-title-font" use-attribute-sets="large-title-font">
  <xsl:attribute name="font-size">16pt</xsl:attribute>
  <xsl:attribute name="font-weight">bold</xsl:attribute>
  <xsl:attribute name="space-after">4pt</xsl:attribute>
  <xsl:attribute name="space-before">2pt</xsl:attribute>
  <xsl:attribute name="font-variant">small-caps</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="work-short-font" use-attribute-sets="large-title-font">
  <xsl:attribute name="font-size">10pt</xsl:attribute>
  <xsl:attribute name="font-weight">bold</xsl:attribute>
  <xsl:attribute name="space-before">2pt</xsl:attribute>
  <xsl:attribute name="space-after">2pt</xsl:attribute>
  <xsl:attribute name="font-variant">small-caps</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="post-title-font" use-attribute-sets="medium-title-font">
  <xsl:attribute name="font-size">10pt</xsl:attribute>
  <xsl:attribute name="font-weight">bold</xsl:attribute>
  <xsl:attribute name="space-after">4pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="name-title-font" use-attribute-sets="verylarge-title-font">
  <xsl:attribute name="font-size">16pt</xsl:attribute>
  <xsl:attribute name="font-weight">bold</xsl:attribute>
  <xsl:attribute name="space-after">8pt</xsl:attribute>
  <!-- <xsl:attribute name="space-before">6pt</xsl:attribute> -->
</xsl:attribute-set>
<xsl:attribute-set name="default-font">
  <xsl:attribute name="font-size">10pt</xsl:attribute>
  <xsl:attribute name="space-after">4pt</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="section-block">
  <!-- <xsl:attribute name="keep-together.within-page">always</xsl:attribute>-->
  <!-- <xsl:attribute name="break-inside">avoid</xsl:attribute> -->
  <!-- <xsl:attribute name="border-before-style">solid</xsl:attribute> -->
  <!-- <xsl:attribute name="border-after-style">solid</xsl:attribute> -->
  <!-- <xsl:attribute name="padding-before">5mm</xsl:attribute> -->
  <xsl:attribute name="space-before">14pt</xsl:attribute>
  <xsl:attribute name="space-before.conditionality">discard</xsl:attribute>
</xsl:attribute-set>
<!-- cv -->
<xsl:template match="cv">
  <xsl:variable name="fullname">
    <xsl:apply-templates mode="fullname" select="identification"/>
  </xsl:variable>
  <root>
    <layout-master-set>
      <simple-page-master master-name="cv"
                        margin-top="1cm" margin-bottom="1cm"
                        margin-left="1cm" margin-right="1cm">
        <region-body margin-top="1cm" margin-bottom="1cm"/>
        <region-before extent="1cm" precedence="true"/>
        <region-after extent="1cm" precedence="true"/>
      </simple-page-master>
      <page-sequence-master master-name="cv-sequence">
        <repeatable-page-master-reference master-reference="cv"/>
      </page-sequence-master>
    </layout-master-set>

    <page-sequence master-reference="cv-sequence">
      <static-content flow-name="xsl-region-before">
        <block border-after-style="solid">
          <table width="100%" table-layout="fixed">
            <table-column column-width="proportional-column-width(1)"
                  number-columns-repeated="2"/>
            <table-body>
              <table-row>
                <table-cell>
                  <block text-align="start"><xsl:value-of select="$fullname"/></block>
                </table-cell>
                <table-cell>
                  <block text-align="end"><xsl:value-of select="$date"/></block>
                </table-cell>
              </table-row>
            </table-body>
          </table>
        </block>
      </static-content>
      <static-content flow-name="xsl-region-after">
        <block border-before-style="solid">
          <table width="100%" table-layout="fixed">
            <table-column column-width="proportional-column-width(1)"
                  number-columns-repeated="2"/>
            <table-body>
              <table-row>
                <table-cell>
                  <block text-align="start"><xsl:value-of select="$cv-uri"/></block>
                </table-cell>
                <table-cell>
                  <block text-align="end">
                    <xsl:call-template name="gentext">
                      <xsl:with-param name="string">str-page</xsl:with-param>
                    </xsl:call-template>
                    <page-number/>
                    <xsl:call-template name="gentext">
                      <xsl:with-param name="string">str-page-of</xsl:with-param>
                    </xsl:call-template>
                    <page-number-citation ref-id="xsl_cv_the_end"/></block>
                </table-cell>
              </table-row>
            </table-body>
          </table>
        </block>
      </static-content>
      <flow flow-name="xsl-region-body" xsl:use-attribute-sets="default-font">
        <block xsl:use-attribute-sets="section-block">
          <xsl:apply-templates select="identification"/>
        </block>
        <block xsl:use-attribute-sets="section-block" space-before.optimum="10pt" space-before.maximum="10pt">
          <block xsl:use-attribute-sets="section-title-font">
            <xsl:call-template name="gentext">
              <xsl:with-param name="string">str-formation</xsl:with-param>
            </xsl:call-template>
          </block>
          <list-block>
            <xsl:apply-templates select="study" mode="short"/>
          </list-block>
        </block>
        <block xsl:use-attribute-sets="section-block">
          <block xsl:use-attribute-sets="section-title-font">
            <xsl:call-template name="gentext">
              <xsl:with-param name="string">str-competences</xsl:with-param>
            </xsl:call-template>
          </block>
          <xsl:apply-templates select="knowledge"/>
          <block keep-together.within-page="always">
            <block xsl:use-attribute-sets="knowledge-title-font">
              <xsl:call-template name="gentext">
                <xsl:with-param name="string">str-languages</xsl:with-param>
              </xsl:call-template>
            </block>
            <table width="100%" table-layout="fixed" margin-left="24pt">
              <table-column column-width="proportional-column-width(1)"
                  number-columns-repeated="2"/>
              <table-body>
                <table-row>
                  <table-cell>
                    <xsl:apply-templates select="language[not(@level='notions' or @level='learning')]"/>
                  </table-cell>
                  <table-cell>
                    <xsl:apply-templates select="language[@level='notions']"/>
                  </table-cell>
                </table-row>
              </table-body>
            </table>
          </block>
        </block>
        <block xsl:use-attribute-sets="section-block">
          <block xsl:use-attribute-sets="section-title-font">
            <xsl:call-template name="gentext">
              <xsl:with-param name="string">str-projects</xsl:with-param>
            </xsl:call-template>
          </block>
          <list-block>
            <xsl:apply-templates select="project|concours" mode="short"/>
          </list-block>
        </block>
        <block xsl:use-attribute-sets="section-block">
          <block xsl:use-attribute-sets="section-title-font">
            <xsl:call-template name="gentext">
              <xsl:with-param name="string">str-hobbies</xsl:with-param>
            </xsl:call-template>
          </block>
          <list-block>
            <xsl:apply-templates select="interest" mode="short"/>
          </list-block>
        </block>
        <block xsl:use-attribute-sets="section-block">
          <block xsl:use-attribute-sets="section-title-font">
            <xsl:call-template name="gentext">
              <xsl:with-param name="string">str-experience</xsl:with-param>
            </xsl:call-template>
          </block>
          <xsl:apply-templates select="work[not(@role='stage' or @role='minor' or @role='old')]"/>
        </block>
	<block xsl:use-attribute-sets="section-block">
          <block xsl:use-attribute-sets="section-title-font">
            <xsl:call-template name="gentext">
              <xsl:with-param name="string">str-otherexperience</xsl:with-param>
            </xsl:call-template>
          </block>
          <table table-layout="fixed"
                 border-collapse="separate" border-separation="5pt">
            <table-column column-width="50%"/>
            <table-column column-width="50%"/>
            <table-body>              
              <xsl:apply-templates select="work[@role='minor' or @role='old']" mode="short"/>
            </table-body>
          </table>
        </block>
	<!--
	<block xsl:use-attribute-sets="section-block">
          <block xsl:use-attribute-sets="section-title-font">
            <xsl:call-template name="gentext">
              <xsl:with-param name="string">str-stage</xsl:with-param>
            </xsl:call-template>
          </block>
          <xsl:apply-templates select="work[@role='stage']" mode="short"/>
        </block>
	-->
        <block visibility="hidden" id="xsl_cv_the_end"/>
      </flow>
    </page-sequence>
  </root>
</xsl:template>

<xsl:template match="knownlist[@level='learning']"/>
<xsl:template match="item[@role='old']" mode="short"/>
<xsl:template match="work[@role='old']">
  <xsl:apply-templates select="." mode="short"/>
</xsl:template>
<xsl:template match="concours[@role='old']" mode="short"/>
<xsl:template match="project[@role='old']" mode="short"/>

<!-- identification section -->
<xsl:template match="identification">
  <table width="100%" table-layout="fixed">
    <table-column column-width="proportional-column-width(1)"
                  number-columns-repeated="2"/>
    <table-body>
    <table-row>
      <table-cell>
      <block xsl:use-attribute-sets="name-title-font"><xsl:apply-templates select="." mode="fullname"/></block>
      <xsl:apply-templates select="title|email" mode="id"/>
      </table-cell>
      <table-cell>
      <xsl:apply-templates mode="id" select="*[name(.) != 'title' and name(.) != 'email']"/>
      </table-cell>
    </table-row>
    </table-body>
  </table>
</xsl:template>
<!-- already process, so skip -->
<xsl:template match="firstname|surname|initials" mode="id"/>
<xsl:template mode="id" match="*">
  <block><xsl:apply-templates select="."/></block>
</xsl:template>
<xsl:template mode="id" match="title">
  <block font-weight="bold"><xsl:apply-templates/></block>
</xsl:template>
<xsl:template mode="id" match="email">
  <block>
    <xsl:call-template name="gentext">
      <xsl:with-param name="string">str-email</xsl:with-param>
    </xsl:call-template>
    <xsl:text>: </xsl:text>
    <xsl:apply-templates/>
  </block>
</xsl:template>
<xsl:template mode="id" match="web">
  <block><xsl:apply-templates/></block>
</xsl:template>
<xsl:template mode="id" match="address">
  <xsl:apply-templates select="."/>
</xsl:template>
<xsl:template mode="id" match="phone">
  <block>
    <xsl:call-template name="gentext">
      <xsl:with-param name="string">        
        <xsl:choose>
          <xsl:when test="@type='fax'">str-phone-fax</xsl:when>
          <xsl:when test="@type='pager'">str-phone-pager</xsl:when>
          <xsl:when test="@type='mobile'">str-phone-mobile</xsl:when>
          <xsl:when test="@type='home'">str-phone-home</xsl:when>
          <xsl:when test="@type='work'">str-phone-work</xsl:when>
          <xsl:otherwise>str-phone</xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
    </xsl:call-template>
    <xsl:text>: </xsl:text>
    <xsl:apply-templates/>
  </block>
</xsl:template>

<!-- work -->
<xsl:template match="work">
  <block space-before="12pt" keep-together="always">
    <xsl:apply-templates/>
  </block>
</xsl:template>
<xsl:template match="work/organism">
  <block xsl:use-attribute-sets="work-title-font"><xsl:apply-templates select="." mode="short"/></block>
</xsl:template>

<!--xsl:template match="work" mode="short">
  <block space-before="10pt" keep-together.within-page="always">
    <block xsl:use-attribute-sets="work-short-font"><xsl:apply-templates select="organism" mode="short"/></block>
    <list-block>
      <xsl:apply-templates select="post" mode="short"/>
    </list-block>
  </block>
</xsl:template-->
<xsl:template match="work" mode="short">
  <table-row keep-together.within-page="always">
    <table-cell>      
      <block xsl:use-attribute-sets="work-short-font"><xsl:apply-templates select="organism" mode="short"/></block>
    </table-cell>
    <table-cell keep-together.within-page="always">
      <list-block>
        <xsl:apply-templates select="post" mode="short"/>
      </list-block>
    </table-cell>
  </table-row>
</xsl:template>
<xsl:template match="post" mode="short">
  <list-item>
    <xsl:call-template name="list-label"/>
    <list-item-body start-indent="body-start()">
      <xsl:if test="title">
        <block>
        <xsl:apply-templates select="title" mode="short"/>
        <xsl:text>; </xsl:text>
        </block>
      </xsl:if>
      <block>
        <xsl:apply-templates select="duration" mode="short"/>
        <xsl:text>.</xsl:text>
      </block>
    </list-item-body>
  </list-item>
</xsl:template>

<!-- post -->
<xsl:template match="post">
  <block keep-together.within-page="always" space-before="6pt">
    <table width="100%" table-layout="fixed">
      <table-column column-width="proportional-column-width(1)"/>
      <table-column column-width="proportional-column-width(1)"/>
      <table-body>
        <table-row>
          <table-cell>
            <xsl:apply-templates select="title" mode="title"/>
          </table-cell>
          <table-cell>
            <xsl:apply-templates select="supervisor|duration" mode="title"/>
          </table-cell>
        </table-row>
      </table-body>
    </table>
    <block margin-left="24pt" space-before="5pt">
      <xsl:apply-templates/>
    </block>
  </block>
</xsl:template>
<xsl:template match="post/supervisor|post/duration|post/title"/>
<xsl:template match="post/title" mode="title">
  <block xsl:use-attribute-sets="post-title-font"><xsl:apply-templates/></block>
</xsl:template>
<xsl:template match="supervisor" mode="title">
  <block>
    <xsl:call-template name="gentext">
      <xsl:with-param name="string">str-supervisor</xsl:with-param>
    </xsl:call-template>
    <xsl:text>: </xsl:text>
    <xsl:apply-templates mode="fullname" select="."/>
  </block>
</xsl:template>
<xsl:template match="post/duration" mode="title">
  <block><xsl:apply-templates/></block>
</xsl:template>

<!-- work/description -->
<!-- post -->
<xsl:template match="work/description">
  <block keep-together.within-page="always" space-before="6pt">
    <xsl:apply-templates/>
  </block>
</xsl:template>

<!-- study -->
<xsl:template match="study" mode="short">
  <list-item>
    <xsl:call-template name="list-label"/>
    <list-item-body start-indent="body-start()">
      <block>
      <xsl:apply-templates select="studydomain"/>
      <xsl:text> (</xsl:text>
      <xsl:apply-templates select="duration"/>
      <xsl:text>), </xsl:text>
      <xsl:apply-templates select="organism" mode="short"/>
      <xsl:text>.</xsl:text>
      </block>
    </list-item-body>
  </list-item>
</xsl:template>

<!-- knowledge -->
<xsl:template match="knowledge">
  <block keep-together.within-page="always">
    <block xsl:use-attribute-sets="knowledge-title-font">
      <xsl:apply-templates select="name"/>
    </block>
    <table width="100%" table-layout="fixed" margin-left="24pt">
      <table-column column-width="proportional-column-width(1)"
          number-columns-repeated="{count(knownlist)}"/>
      <table-header>
        <table-row>
          <xsl:apply-templates select="knownlist" mode="table-header"/>
        </table-row>
      </table-header>
      <table-body>
        <table-row>
          <xsl:apply-templates select="knownlist"/>
        </table-row>
      </table-body>
    </table>
  </block>
</xsl:template>
<xsl:template match="knownlist" mode="table-header">
  <table-cell>
    <block font-weight="bold">
      <xsl:call-template name="gentext">
        <xsl:with-param name="string">          
        <xsl:choose>
          <xsl:when test="@level='notions'" >str-level-notions</xsl:when>
          <xsl:when test="@level='learning'">str-level-learning</xsl:when>
          <xsl:otherwise>str-level-known</xsl:otherwise><!-- 'known' -->
        </xsl:choose>
        </xsl:with-param>
      </xsl:call-template>
      <xsl:text>:</xsl:text>
    </block>
  </table-cell>
</xsl:template>
<xsl:template match="knownlist">
  <table-cell>
    <block><xsl:apply-templates mode="short"/></block>
  </table-cell>
</xsl:template>

<xsl:template match="language">
  <block>
    <xsl:apply-templates/><xsl:text>: </xsl:text>
    <inline font-style="italic" keep-together.within-line="always">
      <xsl:call-template name="gentext">
        <xsl:with-param name="string">          
          <xsl:choose>
            <xsl:when test="@level='notions'" >str-lang-notions</xsl:when>
            <xsl:when test="@level='learning'">str-lang-learning</xsl:when>
            <xsl:when test="@level='functional'" >str-lang-functional</xsl:when>
            <xsl:otherwise>str-lang-known</xsl:otherwise><!-- 'known' -->
          </xsl:choose>
        </xsl:with-param>
      </xsl:call-template>
    </inline>
  </block>
</xsl:template>

<!-- project/concours -->
<xsl:template match="project|concours" mode="short">
  <list-item>
    <xsl:call-template name="list-label"/>
    <list-item-body start-indent="body-start()">
      <block>
        <xsl:apply-templates select="organism" mode="short"/>
        <xsl:text> (</xsl:text>
        <xsl:apply-templates select="duration|year" mode="short"/>
        <xsl:text>);</xsl:text>
        <xsl:if test="description">
          <xsl:text> </xsl:text>
          <xsl:apply-templates select="description" mode="short"/>
        </xsl:if>
      </block>
    </list-item-body>
  </list-item>
</xsl:template>

<xsl:template match="interest" mode="short">
  <list-item>
    <xsl:call-template name="list-label"/>
    <list-item-body start-indent="body-start()">
      <block><xsl:apply-templates mode="short"/></block>
    </list-item-body>
  </list-item>
</xsl:template>

</xsl:stylesheet>