Pages: 1
Print
Author Topic: TOPLEAF: Changing bookmark levels based on context  (Read 5340 times)
jlm05
Member

Posts: 79


« on: January 11, 2012, 02:13:51 PM »

Some of our books are divided into parts, with a bookmark outline that should look something like:

Contents
Preface
    Topic
    Topic
Part 1
     Chapter 1. Chapter title
          Topic
     Chapter 2. Chapter title
Part 2
     Chapter 3. Chapter title
     Chapter 4. Chapter title
Appendix title (formatted like a chapter)
     Topic
     Topic

Currently, the Topic bookmark is configured at level 3. This is fine for the chapters, but for the Preface and Appendix, an empty level 2 bookmark is displayed. I would like to be able to set the Topic bookmark level to 2 if it is within the Preface or Appendix.

The bookmark and TOC levels for Topic are configured by the custom marker %Title[level="topic"].
The bookmark and TOC levels for Appendix are configured by the custom marker %TocApp.
The bookmark and TOC levels for Preface are configured by the custom marker %Title[level="front"].

The Mapping Manager Guide indicates that Custom Markers cannot be given a context. Is there any other way to configure the bookmark to be at a different level when the topic is within the preface or appendix?
Logged
gjn2066
Member

Posts: 60


WWW
« Reply #1 on: January 12, 2012, 09:40:51 PM »

Simple answer "yes". Detailed answer follows:

Firstly, there will be an upgraded TopLeaf plugin for XMetaL 7. This will allow custom markers both to have context and to be part of the context of normal elements (eg. when previously scanned material is re-used).

In the meantime there are several methods for tracking context indirectly. Simplest is to have a user defined variable {Location} (or some such):
  • In $document use
      <set var="Location" string="topic">
    to set the default value.
  • In frontmatter (or preface if you use that)
      <stack var="Location" string="preface">
    will temporarily change the value of {Location} to preface. We use stack rather than set so the value reverts when we leave the preface.
  • Same technique is used for appendix.

We can now use a switch statement:

  <switch>
   <case var="Location" target="preface">

      ... handle preface levels ...
   </case>
   ...
   </switch>


to take care of any special handling.

To say more I'd need to know more about your markup details. DITA is after all a very broad church and numerous variants are possible.

Let me know if this works for you, as there are alternatives if this doesn't suit.

Geoff
« Last Edit: January 12, 2012, 09:43:26 PM by gjn2066 » Logged
jlm05
Member

Posts: 79


« Reply #2 on: April 12, 2012, 09:24:20 AM »

I had implemented this fix, and thought it was working. It still does work, for the front matter, but not for the appendices.

I initialize DocLocation to "topic" in the $document tag.

<set var="DocLocation" string="topic"/>

For the frontmatter tag, add to Custom:

<stack var="DocLocation" string="front"/>

For the appendix tag, add to Custom:

<stack var="DocLocation" string="appendix"/>

For %Title[Level="topic"] (topic level topic within an chapter or appendix).

<switch>
<case var="DocLocation" target="front">
<bookmark level="2"><content/></bookmark>
</case>
<case var="DocLocation" target="appendix">
<bookmark level="2"><content/></bookmark>
</case>
<case var="DocLocation" target="topic">
<bookmark level="3"><content/></bookmark>
</case>
</switch>

The appendices are in a ditamap collection in the bookmap:

<appendix format="ditamap" href="maps/Appendices_collection.ditamap" navtitle="Appendices_collection" scope="local"/>

However, the bookmarks for the top level topics within an appendix are still displaying at level 3 instead of level 2.

Logged
gjn2066
Member

Posts: 60


WWW
« Reply #3 on: April 12, 2012, 09:24:38 PM »

Immediately above the <switch> statement add the line:

   <log message="DL:{DocLocation}"/>

then set the document and check the value of {DocLocation} at the point in question.

If the value is appendix, then get back to me. If it is topic, then you need to check through the log to see where this value is being set.

Geoff

Logged
jlm05
Member

Posts: 79


« Reply #4 on: April 13, 2012, 06:00:44 AM »

Well, as you suspected, the DocLocation variable is never being set to "appendix".

In the log file, the start of the appendix is:

 CONTEXT: /bookmap
     TAG: <topicref class="- map/topicref bookmap/appendix " format="dita" href="maps/../src/cdg_stopwords_root.xml" linking="sourceonly" navtitle="Suggested Stop Words" scope="local" toc="yes" type="concept" xtrc="topicref:1" xtrf="c:\svnfiles\doc\latitude\branches\release-2-2\dev\maps\SuggStopWords_unit.ditamap">
     MAP: topicref
   STACK: var="Context" string="MT"
      IF: (FALSE) var="@class" target="*bookmap/chapter*" test="matches"
      IF: (TRUE) var="@class" target="*bookmap/appendix*" test="matches"
   STACK: var="Context" string="MTA"
     SET: var="AppTitle" string="Suggested Stop Words"


The start of the front matter (which is working) is:

 CONTEXT: /bookmap
     TAG: <frontmatter class="- map/topicref bookmap/frontmatter " xtrc="frontmatter:1" xtrf="c:\svnfiles\doc\latitude\branches\release-2-2\dev\DevGuide_book.ditamap">
     MAP: frontmatter
PAGETYPE: "title" FOLLOWED BY PAGETYPE: "no_header"
   STACK: var="Context" string="MF"
   STACK: var="DocLocation" string="front"


I am not sure why the frontmatter tag is picking up the DocLocation variable, but the appendix tag is not. There is a difference in that "frontmatter" is part of the context for the front matter topics, while "appendix" is not, but I don't know if that's the issue or how to fix it.
Logged
gjn2066
Member

Posts: 60


WWW
« Reply #5 on: April 16, 2012, 05:12:15 AM »

Are you putting the stack command inside an if or case? The stack commands (where present) should be the first thing in the custom content, as they set up a condition whereby the variable is temporarily set, but returns to the prior value on completion. So you can't have one branch stacking and another branch not.

If you don't know what value to stack at first you can just say:
   <stack var="DocLocation" string=""/>
up front, and then set the required value in the normal way thereafter.

Hope this helps. If it doesn't send me the custom content of the frontmatter and topicref mappings (which should correspond to the log entries you sent earlier).
Logged
jlm05
Member

Posts: 79


« Reply #6 on: April 17, 2012, 11:45:32 AM »

I think I got it. I wasn't setting the variable in the topicref map.

I added that to the existing if clause that checked whether the current class was bookmap/appendix, and it looks like it's working now.

Thanks,

Janice
Logged
jlm05
Member

Posts: 79


« Reply #7 on: April 18, 2012, 06:28:13 AM »

Well, it's partly working.

The bookmarks for the top level appendix topics do now display at the correct level (level 2).

However, within the bookmarks (and also within the book and TOC), any structure within the appendices is lost. All topics within an appendix are at the same level, no matter what the structure is in the unit map.
Logged
jlm05
Member

Posts: 79


« Reply #8 on: April 18, 2012, 08:11:15 AM »

Figured the hierarchy issue out too.

Needed additional case statements in the title to accommodate the appendix.
Logged
Pages: 1
Print
Jump to:  

email us