Customizing the Mini TOC, codeblock, and chapter numbers?

765 views
Skip to first unread message

mrob

unread,
Oct 3, 2013, 9:55:07 PM10/3/13
to dita-o...@googlegroups.com
I am new to DITA-OT, using it to convert to PDF. Thus far, I've had good luck making a custom plug-in and figured out many aspects of formatting a template. However, I'm stuck on a few points.

Perhaps somebody could help me with some pointers?

(1) I am trying to change the character style of the mini TOC that appears at the beginning of each chapter. I'd like to use a different font family, color, and no italics. After six or eight hours of tweaking definitions in /cfg/fo/attrs/toc-*, I can't seem to figure this out.

(2) My source DITA makes extensive use of <codeblock> with tab characters to format the code. The DITA-OT treats these tab characters like spaces, so the formatting in the PDF file doesn't look the same. I've googled for a solution but haven't found one.

(3) Instead of regular, sequential page numbers, I'd like to use roman numerals at the beginning of my document, and then chapter-page notation (e.g., 3-15). Is this possible using the DITA-OT? How should I organize my DITA sources for this, and what do I need to do in my DITA-OT plugin?

Any suggestions would be greatly appreciated.

M.


mkaa...@gmail.com

unread,
Oct 4, 2013, 4:51:33 PM10/4/13
to dita-o...@googlegroups.com
I've got item 3 in place.

I'm sure mine isn't optimized but this may help you get started.

Also, it may depend on which version of the OT you are using. Personally, I wouldn't modify the contents of cfg/, I'd make a plugin that overrides cfg/.

Anyway, in common.xsl under:
<xsl:template name="processTopicChapter">
<fo:block xsl:use-attribute-sets="topic">

<fo:marker marker-class-name="current-chapter-number">
    <xsl:for-each select="key('map-id', @id)[1]">
         <xsl:number format="1" count="*[contains(@class, ' bookmap/chapter ')]" />
    </xsl:for-each>
</fo:marker>

In static-contents.xsl I have a lot of:
<pagenum>
    <fo:inline>
       <fo:retrieve-marker retrieve-class-name="current-chapter-number"  />-<fo:page-number/>
    </fo:inline>
</pagenum>

Then in toc.xsl:
Inside of:
<fo:inline xsl:use-attribute-sets="__toc__page-number">

<xsl:if test="not($topicType='topicPart')">
<xsl:for-each select="key('map-id', @id)[1]">
  <xsl:choose>
    <xsl:when test="$topicType='topicAppendix' or ancestor-or-self::*[contains(@class, ' bookmap/appendix ')]"><!-- This was the only way I could figure out what to use to determine the parent type for a child topic -->
      <xsl:number format="A" count="*[contains(@class, ' bookmap/appendix ')]"/>
    </xsl:when>
    <xsl:when test="$topicType='topicChapter' or ancestor-or-self::*[contains(@class, ' bookmap/chapter ')]">
      <xsl:number format="1" count="*[contains(@class, ' bookmap/chapter ')]"/>
    </xsl:when>
    <xsl:otherwise>
<xsl:number format="1" count="*[contains(@class, ' bookmap/chapter ')]"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:for-each>-</xsl:if>
<fo:page-number-citation>
<xsl:attribute name="ref-id">
    <xsl:call-template name="generate-toc-id"/>
</xsl:attribute>
</fo:page-number-citation>

All this stuff could probably use cleanup. I'd greatly appreciate any constructive criticism.

For item 1. I put all of those items in a <preface> tag and use:
<xsl:template name="processTopicPreface">
        <fo:page-sequence master-reference="body-sequence" xsl:use-attribute-sets="__force__page__count" initial-page-number="1" format="I">

I still have a bug where if I have multiple prefaces, some of them contain numbers and some don't. Really struggling to figure out what's going on there as it seems like the numbers follow the preface and it isn't dependent on the order of the prefaces.

On your item 2, my first thought was to figure out <lines> works and see if you can apply that code to <codeblock>. I believe it respects tabs.

mkaa...@gmail.com

unread,
Oct 4, 2013, 4:54:06 PM10/4/13
to dita-o...@googlegroups.com
Oops, roman numerals were in reply to 3. I'm not entirely sure on your mini-toc formatting.

mrob

unread,
Oct 4, 2013, 6:50:44 PM10/4/13
to dita-o...@googlegroups.com
Thanks very much -- I will give this a try!

For item (2), I received a helpful reply off-list that suggested:

  <xsl:template match="*[contains(@class,' pr-d/codeblock ')]//text()">
    <xsl:value-of select="replace(., '\t', '     ')"/>
  </xsl:template>

This seems to work. All of the tabs in codeblocks are now rendered as five spaces.

M.

mrob

unread,
Oct 4, 2013, 8:35:57 PM10/4/13
to dita-o...@googlegroups.com
I tried your suggestion for chapter-page numbers but there is no effect in my PDF output.

Doubtless, I am doing something wrong.

I have a plugin, and am making changes by copying the relevant xsl files from org.dita.pdf2\xsl\fo to the \xsl\fo subdirectory that belongs to my plugin. I then patch those copied files with the changes for chaper-page numbers.

For "common.xsl", I am assuming you mean \xsl\fo\commons.xsl", and for "static-contents.xsl", I am assuming you mean "\xsl\fo\static-content.xsl".

I'm not sure what you mean by "put all of those items in a <preface> tag". Which items?

Finally, I'm wondering if I need to modify some other file, like integrator.xml, in order for my plugin to notice the modified xsl files in \xsl\fo (I'm not entirely clear on how plugins work).

Thanks

Jarno Elovirta

unread,
Oct 4, 2013, 11:17:17 PM10/4/13
to mrob, dita-o...@googlegroups.com
You only need to run integrator if your use *_template.* files or extension points and you modify something in them. For most XSLT changes in PDF customization plug-ins you probably don't need to run integration. However, it doesn't hurt to rerun it when you change your files .

J


--
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

mkaa...@gmail.com

unread,
Oct 5, 2013, 12:05:22 AM10/5/13
to dita-o...@googlegroups.com
Did you setup catalog.xml in your plugin directory? It sounds like you're doing it correctly. It's strange that your codeblock change worked but the rest aren't.

If you haven't already, take a look at:

mrob

unread,
Oct 5, 2013, 7:21:52 PM10/5/13
to dita-o...@googlegroups.com
I didn't use the /Customization directory. I looked at that readme before but the explanation was not comprehensible. It doesn't explain what the directory structure inside the /Customization directory is supposed to look like.

So instead, I just made a new plugin and modified the relevant files in situ. Then, when I run ant, I use the -Dtranstype option to specify my plugin.

Maybe this is the issue(?)

mkaa...@gmail.com

unread,
Oct 7, 2013, 10:23:03 AM10/7/13
to dita-o...@googlegroups.com
You can abandon the customization directory. That topic should probably be updated.

Here's how I'm setup: DITA-OT/plugins/bmx.pdf.axf/

In that directory I have common/, fo/, and catalog.xml
<?xml version="1.0" ?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
    <!-- Custom attributes entry -->
    <uri name="cfg:fo/attrs/custom.xsl" uri="fo/attrs/custom.xsl"/>
    <!-- Custom XSL code entry.-->
    <uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/>
    <!-- FontMapper configuration override entry.-->
    <uri name="cfg:fo/font-mappings.xml" uri="fo/custom_font-mappings.xml"/>
</catalog>

From there your custom.xsl files can directly contain the overrides, or you can use includes.

Example plugins/bmx.pdf.axf/fo/xsl/custom.xsl:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.1">
        <xsl:include href="common.xsl"/>
</xsl:stylesheet>

mrob

unread,
Nov 4, 2013, 9:19:49 PM11/4/13
to dita-o...@googlegroups.com
Sorry, I just don't follow at all what you are suggesting.

I am trying to configure a plug-in that can generate roman numerals at the beginning of my document, and then chapter-page notation (e.g., 3-15).

Some code has been proposed in this thread, but I can't get it to work. It would be helpful if I had the exact, correct directory and file names for where these edits should go.

Could somebody explain this clearly, or is it just not at all possible with DITA-OT?

Thanks

Kristen James Eberlein

unread,
Nov 4, 2013, 9:24:49 PM11/4/13
to dita-o...@googlegroups.com
I suggest that you purchase Leigh White's DITA for Print. It's published by XML Press and available at Amazon.com; it will help you learn to do what you want to do.

Best,
Kris

Kristen James Eberlein
Principal consultant, Eberlein Consulting
Co-chair, OASIS DITA Technical Committee
Charter member, OASIS DITA Adoption Committee
www.eberleinconsulting.com
+1 919 682-2290; kriseberlein (skype)

--

mrob

unread,
Nov 4, 2013, 9:52:35 PM11/4/13
to dita-o...@googlegroups.com
That looks very helpful -- ordered it!

Thanks much,

M.
Reply all
Reply to author
Forward
0 new messages