Page 1 of 1

Can I put a topic as frotmatter page?

Posted: Fri Jan 13, 2023 4:29 am
by Miles Jeong
Hello, I'm kind of newbie in the DITA territory and I've been trying to publish DITA xmls to PDF and HTML.
I want to put a topic as frontmatter page, but unfortunately my customer edits DITA maps, not bookmaps.
I couldn't find any way to do this with CSS or XSL approach.
How can I achieve this?
I'd appreciate any response.
Thanks.

Re: Can I put a topic as frotmatter page?

Posted: Mon Jan 16, 2023 1:02 pm
by julien_lacour
Hello,

One solution could be to add an SVG image containing some text after the frontmatter, like in this example:

Code: Select all

@page frontmatter-page {
  @top-left {content: none;}
  @top-right {content: none;}
  @bottom-center {content: none;}

  background-image: url("frontmatter.svg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

*[class ~= 'front-page/front-page']:after {
  page: frontmatter-page;
  page-break-after: always;
  display: block;
  content: "\2002";
}
The SVG will contains the text of your frontmatter.

Regards,
Julien

Re: Can I put a topic as frotmatter page?

Posted: Mon Jan 16, 2023 1:05 pm
by julien_lacour
Another solution could be to convert the ditamap into a bookmap using Oxygen's XML Refactoring tool or Oxygen XML Scripting if you have a publishing pipeline. Then add the frontmatter into the bookmap.

Then using a small XSLT stylesheet you could be able to add the topic into the bookmap frontmatter.

But without modifying the ditamap, this seems complicated as it will implies a lot of structural modifications.

Regards,
Julien

Re: Can I put a topic as frotmatter page?

Posted: Fri Jan 27, 2023 12:21 pm
by Miles Jeong
I solved my problem via a custom xsl as following.
copied the OOTB xsl part for "opentopic" element and did some customization to put the 1st topic as the frontmatter page
and remove the 1st topic contents from the original position.
Thank you for all your responses.

<!--
Processes the opentopic:map element, this gives the main structure of the TOC.
-->
<xsl:template match="opentopic:map">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="class" select="'- toc/toc '"/>
<!--
copy the contents of the 1st concept in the frontmatter
-->
<frontmatter xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot" class="- map/topicref bookmap/frontmatter ">
<xsl:copy-of select="/map/concept[1]"/>
</frontmatter>
<!--
Adds a title to the TOC.
The title is taken from the toc element @navtitle attribute.
If it does not exist, leave the placeholder element in place
and mark it as empty, so it can be styled from CSS.
-->
<oxy:toc-title class="- toc/title ">
<xsl:variable name="toc-navtitile" select="//toc[1]/@navtitle"/>
<xsl:choose>
<xsl:when test="$toc-navtitile">
<xsl:value-of select="$toc-navtitile"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="empty" select="'true'"/>
</xsl:otherwise>
</xsl:choose>
</oxy:toc-title>

<!--
Adds the TOC main content except the 1st topicref (frontmatter topic)
-->
<xsl:apply-templates select="node() except topicref[1]"/>

<!--
Add a reference to the generated index element,
but only if it contains at least one child and
there is not a reference to the index by means for
a indexlist element in the bookmap.
-->
<xsl:variable name="indexElem" select="//opentopic-index:index.groups[1]"/>
<xsl:if test="$indexElem/* and not (//*[contains(@class, ' bookmap/indexlist ')]) and
$hide.frontpage.toc.index.glossary = 'no'">

<xsl:variable name="indexId" select="generate-id($indexElem)"/>
<topicref is-chapter="true" is-index="true" class="- map/topicref ">
<topicmeta class="- map/topicmeta ">
<navtitle href="#{$indexId}" class="- topic/navtitle ">
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="'Index'"/>
</xsl:call-template>
</navtitle>
</topicmeta>
</topicref>
</xsl:if>
</xsl:copy>
</xsl:template>

<!--
remove the 1st topic contents from the original position
-->
<xsl:template match="*[contains(@class, ' topic/topic concept/concept ') and @is-chapter='true'][1]">

</xsl:template>