[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Current date?
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[@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
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]