Adding topic numbers to webhelp

Post here questions and problems related to editing and publishing DITA content.
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Adding topic numbers to webhelp

Post by Patrik »

I have a use-case where the topic numbers need to be visible not only in the PDF but in the webhelp output as well. While adding this was pretty simple for the pdf it appears to require quite some effort for the webhelp!?

What i got so far is:
  • I modified the build_dita_template.xml to allow a custom value for ditaToc.xsl:

    Code: Select all

    
    [...]
    <if>
    <not>
    <isset property="args.tocDita.xsl"/>
    </not>
    <then>
    <property name="args.dita.out.map.webhelp.tocDita.xsl" value="${webhelp.dir}/xsl/dita/tocDita.xsl"/>
    </then>
    </if>
    <xslt processor="trax"
    in="${dita.temp.dir}/${user.input.file}"
    out="${output.dir}/toc.xml"
    style="${args.dita.out.map.webhelp.tocDita.xsl}"
    [...]
  • In my custom ditaToc.xsl I additionally passed the class attribute to the toc:topic elements to allow different numbering (i.e. hide the number for notices and use letters for an appendices).
  • In my custom createMainFiles.xsl I override the function oxygen:getTopicTitle() to add the number in front of the text.
Now before going further this path I'm wondering:
  1. Is this the right way? For the frames html I would have to adapt additional XSLs... An alternative might be to add a preprocess step that modifies the navtitle element within the ditamap!?
  2. How can I comfortably add the topic number to the topic itself. Sicne each topic is processed individually I have no direct access to the corresponding topicref in the ditamap!?
Thanks and regards,
Patrik
radu_pisoi
Posts: 403
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: Adding topic numbers to webhelp

Post by radu_pisoi »

Hi,
Patrik wrote:Is this the right way? For the frames html I would have to adapt additional XSLs... An alternative might be to add a preprocess step that modifies the navtitle element within the ditamap!?
I didn't try a such customization, so I'm affraid I don't know the right way. The solution that you alredy found seems to be OK.
Patrik wrote:How can I comfortably add the topic number to the topic itself. Sicne each topic is processed individually I have no direct access to the corresponding topicref in the ditamap!?
You can try to find the associated topic in the temporary DITA map by looking for its relative path. The 'dita2webhelp.xsl' stylesheet already receives two parameters: FILEDIR and FILENAME. I think you can use they to compute the path to the topic and then find the associated topic in the DITA map using this path.

The code for computing the topic path might be:

Code: Select all

<!-- Extract the file name without extension -->
<xsl:variable name="FILENAME_WITHOUT_EXT" select="oxygen:getFileName($FILENAME)"/>

<!-- Compute the output file name -->
<xsl:variable name="OUT_FILENAME" select="concat($FILENAME_WITHOUT_EXT, $OUT_FILE_EXT)"/>

<!-- The path for the current file -->
<xsl:variable name="current-file"
select="
translate(
if ($FILEDIR = '.') then
$OUT_FILENAME
else
concat($FILEDIR, '/', $OUT_FILENAME), '\', '/')"/>
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: Adding topic numbers to webhelp

Post by Patrik »

Hi Radu,

thanks for your thoughts. Since I found several other things I'd have to modify (especially all kind of links within the map) I decided to implement it as an additional step in the preprocess.

So if anyone else should have the same requirement and comes across this thread - just tell me and I will make it open-source...

Patrik
Post Reply