DITA and XMetaL Discussion
XMetaL Community Forum › DITA and XMetaL Discussion › TOPLEAF: Changing bookmark levels based on context
-
jlm05 January 11, 2012 at 8:13 pm
TOPLEAF: Changing bookmark levels based on context
January 11, 2012 at 8:13 pmParticipants 7Replies 8Last Activity 11 years agoSome 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
TopicCurrently, 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?
gjn2066 January 13, 2012 at 3:40 am
Reply to: TOPLEAF: Changing bookmark levels based on context
January 13, 2012 at 3:40 amSimple 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
jlm05 April 12, 2012 at 3:24 pm
Reply to: TOPLEAF: Changing bookmark levels based on context
April 12, 2012 at 3:24 pmI 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.
gjn2066 April 13, 2012 at 3:24 am
Reply to: TOPLEAF: Changing bookmark levels based on context
April 13, 2012 at 3:24 amImmediately 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
jlm05 April 13, 2012 at 12:00 pm
Reply to: TOPLEAF: Changing bookmark levels based on context
April 13, 2012 at 12:00 pmWell, 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.
gjn2066 April 16, 2012 at 11:12 am
Reply to: TOPLEAF: Changing bookmark levels based on context
April 16, 2012 at 11:12 amAre 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).
jlm05 April 17, 2012 at 5:45 pm
Reply to: TOPLEAF: Changing bookmark levels based on context
April 17, 2012 at 5:45 pmI 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
jlm05 April 18, 2012 at 12:28 pm
Reply to: TOPLEAF: Changing bookmark levels based on context
April 18, 2012 at 12:28 pmWell, 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.
- In $document use
-
AuthorPosts
- You must be logged in to reply to this topic.