]> granicus.if.org Git - docbook-dsssl/commitdiff
Initial support for timestamp PI. From now you can use <?timestamp format="Y-m-d...
authorJirka Kosek <jirka@kosek.cz>
Mon, 14 Apr 2003 15:22:16 +0000 (15:22 +0000)
committerJirka Kosek <jirka@kosek.cz>
Mon, 14 Apr 2003 15:22:16 +0000 (15:22 +0000)
xsl/common/pi.xsl [new file with mode: 0644]
xsl/fo/docbook.xsl
xsl/html/Makefile.param
xsl/html/docbook.xsl

diff --git a/xsl/common/pi.xsl b/xsl/common/pi.xsl
new file mode 100644 (file)
index 0000000..9a874f0
--- /dev/null
@@ -0,0 +1,160 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
+                xmlns:date="http://exslt.org/dates-and-times"
+                exclude-result-prefixes="doc date"
+                extension-element-prefixes="date"
+                version='1.0'>
+
+<!-- ********************************************************************
+     $Id$
+     ********************************************************************
+
+     This file is part of the XSL DocBook Stylesheet distribution.
+     See ../README or http://nwalsh.com/docbook/xsl/ for copyright
+     and other information.
+
+     This file contains general templates for processing processing
+     instructions common to both the HTML and FO versions of the
+     DocBook stylesheets.
+     ******************************************************************** -->
+
+<!-- Process PIs also on title pages -->
+<xsl:template match="processing-instruction()" mode="titlepage.mode">
+  <xsl:apply-templates select="."/>
+</xsl:template>
+
+<xsl:template match="processing-instruction('timestamp')">
+  <xsl:variable name="format">
+    <xsl:variable name="pi-format">
+      <xsl:call-template name="pi-attribute">
+        <xsl:with-param name="pis" select="."/>
+        <xsl:with-param name="attribute">format</xsl:with-param>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+      <xsl:when test="$pi-format != ''">
+        <xsl:value-of select="$pi-format"/>
+      </xsl:when>
+      <xsl:otherwise>c</xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+
+  <xsl:variable name="padding">
+    <xsl:variable name="pi-padding">
+      <xsl:call-template name="pi-attribute">
+        <xsl:with-param name="pis" select="."/>
+        <xsl:with-param name="attribute">padding</xsl:with-param>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+      <xsl:when test="$pi-padding != ''">
+        <xsl:value-of select="$pi-padding"/>
+      </xsl:when>
+      <xsl:otherwise>1</xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:variable name="date">
+    <xsl:if test="function-available('date:date-time')">
+      <xsl:value-of select="date:date-time()"/>
+    </xsl:if>
+  </xsl:variable>
+
+  <xsl:choose>
+    <xsl:when test="function-available('date:date-time')">
+      <xsl:call-template name="datetime.format">
+        <xsl:with-param name="date" select="$date"/>
+        <xsl:with-param name="format" select="$format"/>
+        <xsl:with-param name="padding" select="$padding"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:message>
+        Timestamp processing requires XSLT processor with EXSLT date support.
+      </xsl:message>
+    </xsl:otherwise>
+  </xsl:choose>
+
+</xsl:template>
+
+<xsl:template name="datetime.format">
+  <xsl:param name="date"/>
+  <xsl:param name="format"/>
+  <xsl:param name="padding" select="1"/>
+  
+  <xsl:if test="$format != ''">
+    <xsl:variable name="char" select="substring($format,1,1)"/>
+
+    <xsl:choose>
+      <xsl:when test="$char = 'a'">
+        <xsl:value-of select="date:day-abbreviation($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'A'">
+        <xsl:value-of select="date:day-name($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'b'">
+        <xsl:value-of select="date:month-abbreviation($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'c'">
+        <xsl:value-of select="date:date($date)"/>
+        <xsl:text> </xsl:text>
+        <xsl:value-of select="date:time($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'B'">
+        <xsl:value-of select="date:month-name($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'd'">
+        <xsl:if test="$padding = 1 and string-length(date:day-in-month($date)) = 1">0</xsl:if>
+        <xsl:value-of select="date:day-in-month($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'H'">
+        <xsl:if test="$padding = 1 and string-length(date:hour-in-day($date)) = 1">0</xsl:if>
+        <xsl:value-of select="date:hour-in-day($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'j'">
+        <xsl:value-of select="date:day-in-year($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'm'">
+        <xsl:if test="$padding = 1 and string-length(date:month-in-year($date)) = 1">0</xsl:if>
+        <xsl:value-of select="date:month-in-year($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'M'">
+        <xsl:if test="string-length(date:minute-in-hour($date)) = 1">0</xsl:if>
+        <xsl:value-of select="date:minute-in-hour($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'S'">
+        <xsl:if test="string-length(date:second-in-minute($date)) = 1">0</xsl:if>
+        <xsl:value-of select="date:second-in-minute($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'U'">
+        <xsl:value-of select="date:week-in-year($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'w'">
+        <xsl:value-of select="date:day-in-week($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'x'">
+        <xsl:value-of select="date:date($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'X'">
+        <xsl:value-of select="date:time($date)"/>
+      </xsl:when>
+      <xsl:when test="$char = 'Y'">
+        <xsl:value-of select="date:year($date)"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$char"/>
+      </xsl:otherwise>
+    </xsl:choose>
+    
+    <!-- Process rest of format specifier -->
+    <xsl:call-template name="datetime.format">
+      <xsl:with-param name="date" select="$date"/>
+      <xsl:with-param name="format" select="substring($format,2)"/>
+      <xsl:with-param name="padding" select="$padding"/>
+    </xsl:call-template>
+  </xsl:if>
+
+</xsl:template>
+
+</xsl:stylesheet>
index 73c11ec76399ea4b973554b5f283b6eec934f5e7..18793979237675f0d32b7ea27f98de1be9431c12 100644 (file)
@@ -31,6 +31,7 @@
 <xsl:include href="../common/titles.xsl"/>
 <xsl:include href="../common/subtitles.xsl"/>
 <xsl:include href="../common/gentext.xsl"/>
+<xsl:include href="../common/pi.xsl"/>
 <xsl:include href="autotoc.xsl"/>
 <xsl:include href="autoidx.xsl"/>
 <xsl:include href="lists.xsl"/>
index 8fa48e860b651947441f23fa7d27d2cfe9cccef7..ea1e1c5e0840070d9816b216d6eec698bf1e94f3 100644 (file)
@@ -231,4 +231,6 @@ PARAMS=../params/admon.graphics.xml \
        ../params/table.footnote.number.symbols.xml \
        ../params/entry.propagates.style.xml \
        ../params/glossentry.show.acronym.xml \
-       ../params/xref.with.number.and.title.xml
+       ../params/xref.with.number.and.title.xml \
+       ../params/ebnf.assignment.xml \
+       ../params/ebnf.statement.terminator.xml
index 5c4d6613235a845fb32120202370763ec8996e2f..5311c66adf71752213ed421ee54432b90396169e 100644 (file)
@@ -30,6 +30,7 @@
 <xsl:include href="../common/subtitles.xsl"/>
 <xsl:include href="../common/gentext.xsl"/>
 <xsl:include href="../common/targets.xsl"/>
+<xsl:include href="../common/pi.xsl"/>
 <xsl:include href="autotoc.xsl"/>
 <xsl:include href="autoidx.xsl"/>
 <xsl:include href="lists.xsl"/>