Re: PDF header customization; adding product version


Dave C
 

This is a great example, thanks for posting the info!

Dave C.

--- In dita-users@yahoogroups.com, "Chris Johnson" <chris.johnson@...> wrote:

Hey Shawn,

To change the headers for FO processing, I had to modify two files files
in my customization directory:

1. demo/fo/Customization/fo/xsl/custom.xsl

2. demo/fo/Customization/fo/common/vars/en_US.xsl


In my custom.xsl (1.), I need to add two templates: one template to set
a variable for the product version, and another template to override the
header I want to customize.

<!-- set product version -->
<!-- See also demo/fo/cfg/common/vars/en_US.xml --> <xsl:variable
name="productVersion">
<xsl:variable name="mapProdVersion"
select="/*/*[namespace-uri()='http://www.idiominc.com/opentopic' and
local-name()='map']/topicmeta/prodinfo/vrmlist/vrm/@version"/>
<xsl:variable name="bkinfoProdVersion" select="/*/*[contains(@class, '
bkinfo/bkinfo ')]/prodinfo/vrmlist/vrm/@version"/>
<xsl:choose>
<xsl:when test="$mapProdVersion">
<xsl:value-of select="$mapProdVersion"/>
</xsl:when>
<xsl:when test="$bkinfoProdVersion">
<xsl:value-of select="$bkinfoProdVersion"/>
</xsl:when>
<xsl:otherwise>
<xsl:message>Could not set product version</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

Now that I have the variable, I can override the header template, adding
a new parameter "prodversion" to the insertVariable call:

<!-- Body headers and footers (see demo/fo/xsl/fo/static-content.xsl)
--> <xsl:template name="insertBodyOddHeader"> <fo:static-content
flow-name="odd-body-header">
<fo:block xsl:use-attribute-sets="__body__odd__header">
<xsl:call-template name="insertVariable">
<xsl:with-param name="theVariableID" select="'Body odd header'"/>
<xsl:with-param name="theParameters">
<prodname>
<xsl:value-of select="$productName"/>
</prodname>
<prodversion>
<xsl:value-of select="$productVersion"/>
</prodversion>
<heading>
<fo:inline
xsl:use-attribute-sets="__body__odd__header__heading">
<fo:retrieve-marker retrieve-class-name="current-header"/>
</fo:inline>
</heading>
<pagenum>
<fo:inline
xsl:use-attribute-sets="__body__odd__header__pagenum">
<fo:page-number/>
</fo:inline>
</pagenum>
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:static-content>


Now I have called the insertVariable template, with the new
"prodversion" parameter, I need to modify the en_US.xsl file (2.) to use
the prodversion parameter:

<!-- The header that appears on odd-numbered pages. --> <variable
id="Body odd header"><param ref-name="prodname"/>&#xA0;<param
ref-name="prodversion"/>&#xA0;|&#xA0;<param
ref-name="heading"/>&#xA0;|&#xA0;<param ref-name="pagenum"/></variable>

This seems to work for me - YMMV.


HTH,


-Chris

-
Chris Johnson
Consultant Developer
XMetaL, a JustSystems company


________________________________________________________________________

1c. Re: "Open Topic" in PDF header? Where is this coming from?
Posted by: "Shawn McKenzie" smckenzie23@... smckenzie23
Date: Wed Nov 15, 2006 2:03 pm ((PST))

I'm having problems with this as well. I updated the en_US.xml file and
that works. The problem is that I am working on multiple projects with
the toolkit, so I would like it to pull this information from the
ditamap. So, I added the following to my ditamap:

<topicmeta>
<prodinfo>
<prodname>WS1000</prodname>
<vrmlist>
<vrm version="1.0"/>
</vrmlist>
</prodinfo>
</topicmeta>

I don't really want the vrm element, but it seems it needs to be there
to be valid. Unfortunately, that causes errors with the FO generation.
When I have a topicmeta as above, I get the following:

transform.fo2pdf:
[java] ERROR: Element 'fo:block-container' cannot be a child of
'fo:root'.
[java] ERROR: Attribute 'bottom' cannot occur at element
'fo:block-container'.
[java] ERROR: Attribute 'left' cannot occur at element
'fo:block-container'.
[java] ERROR: Attribute 'position' cannot occur at element
'fo:block-container'.
[java] ERROR: Attribute 'right' cannot occur at element
'fo:block-container'.
[java] ERROR: Attribute 'top' cannot occur at element
'fo:block-container'.
[java] Rendering failed: Invalid XSL FO source
'file:/Users/shawnm/Perforce/Documentation/DITA-OT1.2.2/output/ws1000/pd
f/ws1000/topic.fo':
6 errors found during validation
[java] Java Result: 1

Join main@dita-users.groups.io to automatically receive all group messages.