Page 1 of 1

Add page break to topicref at map level

Posted: Wed Feb 14, 2018 12:56 am
by BobbyG66
We are trying to add a page break outputclass to topicrefs at the map level.
We have a custom page break attribute that we have working for individual topics, but we want to use it at the map level.

Our code is this:
[Codebox=]
<xsl:template match="*[contains(@class, ' map/topicref ')]">
<fo:block xsl:use-attribute-sets="topicref">
<xsl:if test="contains(@outputclass, 'page_break')"><!-- Added page break for topicref. -->
<fo:block page-break-before="always"/>
</xsl:if>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
[/Codebox]

We have added this code to this file:

Code: Select all

/plugins/CUSTOM PLUGIN/cfg/fo/xsl/map-elements.xsl
Tried different variations of the code with no luck.
Are we using the correct xsl file?
Is the code right?

Any help is appreciated.
Thanks
BG66

Re: Add page break to topicref at map level

Posted: Wed Feb 21, 2018 10:05 am
by Dan
You should move the outputclass attribute to the "topic" element, and change your XSL match to <xsl:template match="*[contains(@class, ' topic/topic ')]">. Avoid matching topicrefs, these go into the TOC section of the publication.

Another way is to use the technique discussed here: http://blog.oxygenxml.com/2015/04/dita- ... mment-form

A good resource is the general DITA discussion list, there are lots of posts here:
https://groups.google.com/forum/#!forum/dita-ot-users

Regard,
Dan

Re: Add page break to topicref at map level

Posted: Wed Feb 21, 2018 3:16 pm
by BobbyG66
Thanks Dan,

We have been using page breaks at the topic level.
The problem is, that we have a lot of common topics, that are used in many different manuals and locations.
If we add a page break to that topic, it will break all the time.
Sometimes we want that topic to break, sometimes we don't.

I figured that controlling it at the map level would be the best option. That way we keep the topic without the page break, and depending on the map, apply the break there.

Has anyone done anything like this?
The other option we considered way to create a duplicate topic. One would break, the other would not. Then we just insert the one we need into the map.
But this seems like a lot more to manage and track. And is not as simple or elegant as we would like.

Thanks
Bob

Re: Add page break to topicref at map level

Posted: Wed Feb 21, 2018 5:33 pm
by Dan
Maybe you can use conrefs? Create a shell topic that has the outputclass set on it that includes the content of the real topic? But maybe dita-users is a better place to find out an answer.

Re: Add page break to topicref at map level

Posted: Fri Mar 02, 2018 12:59 am
by BobbyG66
Thanks Dan,

We could use conrefs, but that would create two topics. We would like to just use one topic and control it at the map level.
The topicrefs in the map do have an outputclass available, I just can't find where to apply the code.

I have cross posted on the DITA-users site.

Thanks
Bob

Re: Add page break to topicref at map level

Posted: Fri Mar 02, 2018 11:31 am
by Dan
The "map/topicref" elements from the TOC section have the same @id attribute as the topics they point to in the main content.

I recomend to the the following:
Change your template to match the "topic/topic" elements. Use the @id attribute of the matched elements to find the corresponding "map/topicref" from the TOC. Copy the @outputclass attribute from the "map/topicref" element to the "topic/topic".

I hope this helps,
Many regards,
Dan

Re: Add page break to topicref at map level

Posted: Fri May 04, 2018 8:53 am
by Dan
For clarity I add here an XSL snippet (it should be added to your customization XSL for the PDF2 DITA-OT plugin).

It contains a modified copy of the template from the DITA-OT\plugins\org.dita.pdf2\xsl\fo\commons.xsl stylesheet:

Code: Select all



<xsl:template match="*" mode="commonTopicProcessing">

<xsl:variable name="topicref" select="key('map-id', ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id)"/>

<xsl:if test="empty(ancestor::*[contains(@class, ' topic/topic ')])">
<fo:marker marker-class-name="current-topic-number">
<!-- Moved outside the if block: -->
<!-- <xsl:variable name="topicref" select="key('map-id', ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id)"/>-->
<xsl:for-each select="$topicref">
<xsl:apply-templates select="." mode="topicTitleNumber"/>
</xsl:for-each>
</fo:marker>
</xsl:if>
<fo:block>

<!-- The page break class from the topicref becomes the page-break-before attribute -->
<xsl:if test="contains($topicref/@outputclass, 'page-break-before')">
<xsl:attribute name="page-break-before" select="'always'"/>
</xsl:if>
<xsl:if test="contains($topicref/@outputclass, 'page-break-after')">
<xsl:attribute name="page-break-after" select="'always'"/>
</xsl:if>

<xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="flag-attributes"/>
<xsl:apply-templates select="*[contains(@class, ' topic/title ')]"/>
<xsl:apply-templates select="*[contains(@class, ' topic/prolog ')]"/>
<xsl:apply-templates select="*[not(contains(@class, ' topic/title ')) and
not(contains(@class, ' topic/prolog ')) and
not(contains(@class, ' topic/topic '))]"/>
<!--xsl:apply-templates select="." mode="buildRelationships"/-->
<xsl:apply-templates select="*[contains(@class,' topic/topic ')]"/>
<xsl:apply-templates select="." mode="topicEpilog"/>
</fo:block>
</xsl:template>
It works for plain map topicrefs (not bookmap chapters or other elements that are treated in a special way by the PDF2 DITA-OT plugin).

Many regards,
Dan

Re: Add page break to topicref at map level

Posted: Fri May 04, 2018 2:19 pm
by BobbyG66
Thanks Dan,

Will have to give this a try.

Bob