Thanks Jirka!
Note that this specific enhancement has already been requested by a user
and that we planned to implement it for next release. This patch is
especially useful not only because it is well-coded, but also because it
somewhat clarifies the RFE made by our user (which also had special
needs for the *first* page of a chapter).
On 02/20/2012 04:23 PM, Jirka Kosek wrote:
> Hi,
>
> please find below extended version of functions which adds support for
> {odd|even}-{chapter|document}-title pseudo-variables for
> headers/footers. In many document with double-sided output different
> content has to be used on odd and even pages.
Understood.
>
> Also it would be nice if there is an easy way for specifying different
> column widths separately for table used on odd and even pages for
> header/footer. In many documents title are so long that they occupy
> almost full width, but they are switching between left and right table
> column for even/odd pages.
Understood.
>
> Jirka
>
> <xsl:function name="u:expandHeaderOrFooter" as="item()*">
> <xsl:param name="imageSpec" as="xs:string"/>
> <xsl:param name="textSpec" as="xs:string"/>
>
> <xsl:param name="pageNumber" as="item()*"/>
> <xsl:param name="isEven" as="xs:boolean"/>
> <xsl:param name="pageCount" as="item()*"/>
> <xsl:param name="chapterTitle" as="item()*"/>
> <xsl:param name="documentTitle" as="item()*"/>
>
> <xsl:variable name="oddPageNumber"
> select="if ($two-sided = 'yes' and $isEven)
> then ()
> else $pageNumber"/>
>
> <xsl:variable name="evenPageNumber"
> select="if ($two-sided = 'yes' and $isEven)
> then $pageNumber
> else ()"/>
>
> <xsl:variable name="oddChapterTitle"
> select="if ($two-sided = 'yes' and $isEven)
> then ()
> else $chapterTitle"/>
>
> <xsl:variable name="evenChapterTitle"
> select="if ($two-sided = 'yes' and $isEven)
> then $chapterTitle
> else ()"/>
>
> <xsl:variable name="oddDocumentTitle"
> select="if ($two-sided = 'yes' and $isEven)
> then ()
> else $documentTitle"/>
>
> <xsl:variable name="evenDocumentTitle"
> select="if ($two-sided = 'yes' and $isEven)
> then $documentTitle
> else ()"/>
>
> <xsl:choose>
> <xsl:when test="$imageSpec != ''">
> <xsl:variable name="imageURI"
> select="resolve-uri($imageSpec,
> URI:userDirectory())"/>
>
> <fo:external-graphic src="{concat('url(', $imageURI, ')')}"/>
> </xsl:when>
>
> <xsl:when test="$textSpec != ''">
> <xsl:variable name="textSpec2">
> <xsl:choose>
> <xsl:when test="contains($textSpec, '^') and
> not(contains($textSpec, '%'))">
> <!-- Support ^page-number^ rather than %page-number%. -->
> <xsl:value-of
> select="translate(replace($textSpec, '\^\^', ''),
> '^', '%')" />
> </xsl:when>
>
> <xsl:otherwise>
> <!-- belongs to Unicode Basic Multilingual Plane
> Private Use Area: U+E000 to U+F8FF -->
> <xsl:value-of select="replace($textSpec, '%%', '')" />
> </xsl:otherwise>
> </xsl:choose>
> </xsl:variable>
>
> <xsl:sequence
> select="for $t in tokenize($textSpec2, '%')
> return
> if ($t = 'page-number') then $pageNumber
> else
> if ($t = 'odd-page-number') then $oddPageNumber
> else
> if ($t = 'even-page-number') then $evenPageNumber
> else
> if ($t = 'page-count') then $pageCount
> else
> if ($t = 'chapter-title') then $chapterTitle
> else
> if ($t = 'odd-chapter-title') then
> $oddChapterTitle
> else
> if ($t = 'even-chapter-title') then
> $evenChapterTitle
> else
> if ($t = 'document-title') then
> $documentTitle
> else
> if ($t = 'odd-document-title') then
> $oddDocumentTitle
> else
> if ($t = 'even-document-title')
> then $evenDocumentTitle
> else
> if ($t != '')
> then replace(replace($t,
> '', '^'),
> '', '%')
> else ()"/>
> </xsl:when>
>
> <xsl:otherwise>
> <xsl:sequence select="()"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:function>
>
--
XMLmind DITA Converter Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/ditac-support