Created
April 23, 2012 21:17
-
-
Save infotexture/2473924 to your computer and use it in GitHub Desktop.
DITA-OT Customization: Numbered Headings in PDF output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8'?> | |
<xsl:stylesheet version="2.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<!-- | |
Numbered Headings in PDF output per <http://tech.groups.yahoo.com/group/dita-users/message/26819>, 26827, 26828 & 26794 | |
Template created via DITA-OT PDF plug-in generator <http://dita-generator.appspot.com/pdf-plugin> by Jarno Elovirta --> | |
<xsl:template match="*" mode="getTitle"> | |
<xsl:variable name="topic" select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]" /> | |
<xsl:variable name="id" select="$topic/@id" /> | |
<xsl:variable name="mapTopics" select="key('map-id', $id)" /> | |
<fo:inline> | |
<xsl:for-each select="$mapTopics[1]"> | |
<xsl:choose> | |
<xsl:when test="parent::opentopic:map" /> | |
<xsl:when test="ancestor-or-self::*[contains(@class, ' bookmap/frontmatter ') or contains(@class, ' bookmap/backmatter ')]" /> | |
<xsl:when test="ancestor-or-self::*[contains(@class, ' bookmap/appendix ')]"> | |
<xsl:number count="*[contains(@class, ' map/topicref ')] [ancestor-or-self::*[contains(@class, ' bookmap/appendix ')]]" format="A.1.1" level="multiple" /> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:number count="*[contains(@class, ' map/topicref ')] [not(ancestor-or-self::*[contains(@class, ' bookmap/frontmatter ')])]" format="1.1" level="multiple" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:for-each> | |
</fo:inline> | |
<xsl:text> </xsl:text> | |
<xsl:apply-templates /> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I saw your post on the dita-users yahoo group and am trying to implement this code, so i can get numbered headings. Aside from adding this code to a custom file or the custom.xsl file (as the plugin generator does), what other customizations are required? I added the code to my /fo/xsl/custom.xsl file and got the following error when I attempted run my XEP transform:
[java] Error at xsl:when on line 13 column 62 of custom.xsl:
[java] XPST0081 XPath syntax error at char 21 on line 13 in {parent::opentopic:map}:
[java] Undeclared namespace prefix {opentopic}
[java] Failed to compile stylesheet. 1 error detected.
Do you know what and where I need to make a declaration?
TIA,
Qiana