Pages: 1
Print
Author Topic: displaying date output is generated  (Read 7293 times)
IF
Member

Posts: 80


« on: September 24, 2010, 11:41:48 AM »

In XMetal 6.0, is there a way to display in the output (HTML or XMetal Enhanced PDF via Render XEP) the date/time on which the output was generated? Thanks.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: September 24, 2010, 02:35:47 PM »

The date and time of production can be viewed (in Adobe Reader anyway) by opening the Document Properties dialog. I assume what you really want is to include this information somewhere directly within the visible portion of the PDF (and HTML). Can you elaborate on where you want this information to appear and what date/time format you wish it to be in?

Two different source for the date/time I can think of and it isn't clear which you want:

1. Hard-code the date into your map (or topic) using the elements DITA provides for this, then adjust the DITA OT transformation to extract this information and place it in the location you wish it to appear in your output. Maybe something like this:

<?xml version="1.0"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<!-- Created with XMetaL (http://www.xmetal.com) -->
<map id="map_FE080B8C1EA24D55A27707D9C139C86B">
  <topicmeta>
    <critdates>
      <created date="2010-01-12"/>
      <revised modified="2010-09-24"/>
    </critdates>
  </topicmeta>
</map>


A date attribute is also present on the following elements:
<published> (this is the most likely one to use depending on what you are after)
<started>
<completed>

Note that <started> and <completed> appear inside various elements that give more context, like <approved>, <reviewed>, etc.

A year attribute is present on the following elements:
<copyrfirst>
<copyrlast>


2. Modify the DITA OT in some way to obtain the date/time from the system (and again, insert it into the document somewhere). This would better reflect the actual time of "printing". There are apparently some extensions to XSLT that provide date and time functions, however, I have not used these. I'm not sure if they will work with all XSLT processors either.
Logged
IF
Member

Posts: 80


« Reply #2 on: September 27, 2010, 02:43:09 PM »

The scenario in option 1 is what I was thinking. So basically, my question becomes: how do I show the value of    <created date="2010-01-12"/> in the PDF output?

Thanks. Isabelle
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #3 on: September 27, 2010, 06:50:33 PM »

There's not quite enough detail here to give you an explicit answer but one way to do this might be to define a new parameter:

<!-- document creation date -->
    <xsl:param name="documentCreatedDate">
        <xsl:for-each select="//topicmeta/critdates/created">
         <xsl:value-of select="@date"/>
      </xsl:for-each>
    </xsl:param>


Then insert this where you want to insert it using $documentCreatedDate. So, for example, if you wanted to have this appear in even (page numbered) footers inside the document body you could redefine the other parameters that are defined for that purpose:

    <xsl:param name="__body__even__footer__Cols">1 1 1</xsl:param>
    <xsl:param name="__body__even__footer__col_1" select="$xmPageNumber"/>
    <xsl:param name="__body__even__footer__col_2">no-op</xsl:param>
    <xsl:param name="__body__even__footer__col_3" select="$documentCreatedDate"/>


If you were to put all of the code above into %appdata%\SoftQuad\XMetaL Shared\DITA_OT\demo\xmfo\Customization\fo\xsl\custom.xsl (which is where I would suggest you put any overrides) then you should see the value for the date attribute appear on evenly numbered pages inside the document "body" (as opposed to evenly numbered pages, or the TOC, Index, etc).

Note that as written above the XPath is specific to DITA Maps and is not "specialization savvy".

If you want the value for this element's date attribute to show up on the cover page you could modify the xm_titlepage.xsl directly (or perhaps ideally, do an override like above, but instead to <xsl:template name="createFrontMatter"> in which case you'd need to duplicate the entire template and then insert your new code into it).

You would be inserting something like the following into that template where you want the new content to appear (possibly after the "for-each" that inserts the subtitle):

<xsl:for-each select="$map//*[contains(@class, ' topic/created ')]">
    <fo:block xsl:use-attribute-sets="xm.titlepage.subtitle">
        <xsl:text>Created: </xsl:text>
        <xsl:value-of select="@date"/>
    </fo:block>
</xsl:for-each>

I've reused xsl:use-attribute-sets="xm.titlepage.subtitle" for the styling here so that a new one doesn't need to be made up. You could create your own or use another one that already exists if you need this text to be styled differently.

Note that this XPath is specialization-savvy.
Logged
IF
Member

Posts: 80


« Reply #4 on: September 28, 2010, 04:56:32 PM »

Thanks for the very detailed answer.  I got this to work but best of all a light bulb went on and I finally understand how to make the rest of my required changes in order to get a PDF output I can live with.
Logged
IF
Member

Posts: 80


« Reply #5 on: November 25, 2010, 11:21:20 AM »

FYI -  to close the loop
This is what I ended up doing for my draft documents:

In the footer, I have added a date that indicates when the output was generated, as per the instructions in http://forums.xmetal.com/index.php/topic,150.0.html

I also print the create date and revised dates found in the prolog of each topic using this template:
 <xsl:template match="*[contains(@class, ' topic/prolog ')]">
    <xsl:if test="*[contains(@class,' topic/critdates ')]/*[contains(@class,' topic/created ')]/@date">
      Topic created on:  <xsl:value-of select="*[contains(@class,' topic/critdates ')]/*[contains(@class,' topic/created ')]/@date"/>
    </xsl:if>
    <xsl:if test="*[contains(@class,' topic/critdates ')]/*[contains(@class,' topic/revised ')]/@modified">
    <xsl:for-each select="child::*[contains(@class,' topic/critdates ')]/*[contains(@class,' topic/revised ')]">
     <fo:block> Revised on:  <xsl:value-of select="@modified"/> </fo:block>
     </xsl:for-each>
    </xsl:if>
  </xsl:template>
Logged
gcrews
Member

Posts: 265


« Reply #6 on: November 25, 2010, 11:55:10 AM »

For a pdf we use  the EXSLT date and time functions.
http://www.exslt.org/date/functions/time/index.html
I think it takes a little bit to get it working.
Logged
Pages: 1
Print
Jump to: