DITA and XMetaL Discussion

XMetaL Community Forum DITA and XMetaL Discussion TOPLEAF: Changing bookmark levels based on context

  • jlm05

    TOPLEAF: Changing bookmark levels based on context

    Participants 7
    Replies 8
    Last Activity 10 years, 8 months ago

    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?

    Reply

    gjn2066

    Reply to: TOPLEAF: Changing bookmark levels based on context

    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
       
      to set the default value.
    • In frontmatter (or preface if you use that)
        <[u]stack[/u] 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:

     
     

         … handle preface levels …
     
      …
     

    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

    Reply

    jlm05

    Reply to: TOPLEAF: Changing bookmark levels based on context

    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.

    For the frontmatter tag, add to Custom:

    For the appendix tag, add to Custom:

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











    The appendices are in a ditamap collection in the bookmap:

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

    Reply

    gjn2066

    Reply to: TOPLEAF: Changing bookmark levels based on context

    Immediately above the statement add the line:

     

    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

    Reply

    jlm05

    Reply to: TOPLEAF: Changing bookmark levels based on context

    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:
        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:
        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.

    Reply

    gjn2066

    Reply to: TOPLEAF: Changing bookmark levels based on context

    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:
     
    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).

    Reply

    jlm05

    Reply to: TOPLEAF: Changing bookmark levels based on context

    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

    Reply

    jlm05

    Reply to: TOPLEAF: Changing bookmark levels based on context

    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.

    Reply

    jlm05

    Reply to: TOPLEAF: Changing bookmark levels based on context

    Figured the hierarchy issue out too.

    Needed additional case statements in the title to accommodate the appendix.

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support