This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: [docbook-apps] Current date?
- From: Rune Enggaard Lausen <rune at enggaard-lausen dot dk>
- To: Mailing List <mailinglist dot 01 dot 1 at goolo dot com>
- Cc: Brian Burridge <brian at burridge dot net>, DocBookApps <docbook-apps at lists dot oasis-open dot org>
- Date: Wed, 02 Apr 2003 13:30:05 +0200
- Subject: Re: [docbook-apps] Current date?
- References: <1048863783.1339.0.camel@mi6.local> <3E8ABFF2.3090009@goolo.com>
Mailing List wrote:
* generate a timestamp (this is a M$-DOS example)
echo %date% %time% >timestamp.txt
* declare this file as an entity:
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "docbookx.dtd" [
...
<!ENTITY timestamp SYSTEM "timestamp.txt">
...
]>
* and use it
<pubdate>×tamp;</pubdate>
Neat!
If you are willing to rely on EXSLT support in the XSLT processor, you
could do like I did in our XSL-FO customization layer. It works with
Saxon and xsltproc. Don't know about Xalan.
Here is what I did:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xlink='http://www.w3.org/1999/xlink'
xmlns:date="http://exslt.org/dates-and-times"
exclude-result-prefixes="xlink"
version="1.0">
<!-- Note the xmlns:date="..." above -->
<!-- SNIP (Imports and other customizations) -->
<!--
Template formatted for readability.
May produce extra blanks.
Add number formatting to ensure two digits in
time fields.
-->
<xsl:template match="pubdate[ at role='now']" mode="titlepage.mode">
<xsl:variable name="now" select="date:date-time()"/>
<fo:block>
<xsl:text>Generated at </xsl:text>
<xsl:value-of select="date:day-in-month($now)"/>
<xsl:text> </xsl:text>
<xsl:value-of select="date:month-name($now)"/>
<xsl:text> </xsl:text>
<xsl:value-of select="date:year($now)"/>
<xsl:text> </xsl:text>
<xsl:value-of select="date:hour-in-day($now)"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="date:minute-in-hour($now)"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="date:second-in-minute($now)"/>
</fo:block>
</xsl:template>
<!-- ETC -->
</xsl:stylesheet>
Document:
<!DOCTYPE book PUBLIC "..." "...">
<book lang="en">
<bookinfo>
<title>Blah blah/title>
<pubdate role="now"/>
<!-- ETC -->
</bookinfo>
<!-- ETC -->
</book>
Best regards,
Rune Lausen
---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe at lists dot oasis-open dot org
For additional commands, e-mail: docbook-apps-help at lists dot oasis-open dot org