This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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>&timestamp;</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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]