common.xsl
author Fabien Ninoles <fabien@tzone.org>
Mon, 14 Sep 2015 11:30:58 -0400
branchstyles
changeset 19 42559b9800a7
parent 0 08de8d15f932
permissions -rw-r--r--
Phony install

<?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">
  
<xsl:template name="get-id">    
  <xsl:choose>
    <xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
    <xsl:otherwise><xsl:value-of select="generate-id(.)"/></xsl:otherwise>
  </xsl:choose>
</xsl:template>
<xsl:template name="parent-id">
  <xsl:choose>
    <xsl:when test="../@id"><xsl:value-of select="../@id"/></xsl:when>
    <xsl:otherwise><xsl:value-of select="generate-id(..)"/></xsl:otherwise>
  </xsl:choose>
</xsl:template>
<xsl:template name="next-id">
  <xsl:choose>
    <xsl:when test="following::*[1]/@id"><xsl:value-of select="following::*[1]/@id"/></xsl:when>
    <xsl:otherwise><xsl:value-of select="generate-id(following::*[1])"/></xsl:otherwise>
  </xsl:choose>
</xsl:template>
<xsl:template name="prec-id">
  <xsl:choose>
    <xsl:when test="preceding::*[1]/@id"><xsl:value-of select="preceding::*[1]/@id"/></xsl:when>
    <xsl:otherwise><xsl:value-of select="generate-id(preceding::*[1])"/></xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="*" mode="fullname">
  <xsl:call-template name="name"/>  
</xsl:template>

<!-- default docinfo processing -->
<!-- normal is not process -->
<xsl:template match="docinfo"/>

<!-- copyright footer processing -->
<xsl:template match="copyright">
  © <xsl:apply-templates select="holder"/>
  <xsl:text> </xsl:text>
  <xsl:apply-templates select="year"/>
</xsl:template>
<xsl:template match="holder">
  <xsl:call-template name="name"/>
</xsl:template>
<xsl:template match="year">
  <xsl:apply-templates/>
  <xsl:if test="position() != last()">
    <xsl:text>, </xsl:text>
  </xsl:if>
</xsl:template>

<!-- author processing -->
<xsl:template match="author">
  <xsl:call-template name="name"/> 
</xsl:template>

<!-- short representation -->
<xsl:template match="para" mode="short">
  <xsl:apply-templates/>  
</xsl:template>
<xsl:template match="list" mode="short">
  <xsl:param name="ending">
    <xsl:text>.</xsl:text>
  </xsl:param>
  <xsl:apply-templates mode="short">
    <xsl:with-param name="ending" select="$ending"/>
  </xsl:apply-templates>
</xsl:template>
<xsl:template match="listitem" mode="short">
  <xsl:apply-templates mode="short"/><xsl:text>, </xsl:text>
</xsl:template>
<xsl:template match="listitem[position() = last()]" mode="short">
  <xsl:param name="ending">
    <xsl:text>.</xsl:text>
  </xsl:param>
  <xsl:apply-templates mode="short"/><xsl:value-of select="$ending"/>
</xsl:template>
<xsl:template match="item" mode="short">
  <xsl:apply-templates/><xsl:text>, </xsl:text>
</xsl:template>
<xsl:template match="item[position() = last()]" mode="short">
  <xsl:param name="ending">
    <xsl:text>.</xsl:text>
  </xsl:param>
  <xsl:apply-templates/><xsl:value-of select="$ending"/>
</xsl:template>

</xsl:stylesheet>