oxygenxml / dita-classic-pdf-landscape-sample

PDF plugin which allows you to define landscape pages for a certain chapter
Apache License 2.0
6 stars 1 forks source link

Processing only works on chapter level #2

Open stefan-jung opened 3 years ago

stefan-jung commented 3 years ago

This only works on <chapter> level. This might be insufficient, e.g. in multilanguage deliverables.

English <!-- Chapter level -->
  Chapter 1 <!-- Topic level -->
  Chapter 2 <!-- Topic level -->
  Chapter 3 <!-- Topic level -->
German <!-- Chapter level -->
  Chapter 1 <!-- Topic level -->
  Chapter 2 <!-- Topic level -->
  Chapter 3 <!-- Topic level -->

When trying to apply this on <topic> level, I get the following error:

org.apache.fop.apps.FOPException: net.sf.saxon.trans.XPathException: org.apache.fop.fo.ValidationException:
"fo:page-sequence" is not a valid child of "fo:block"! (See position 12:2606)
net.sf.saxon.trans.XPathException: org.apache.fop.fo.ValidationException: "fo:page-sequence" is not a valid child of 
"fo:block"! (See position 12:2606)

To trigger this, you can avoid triggering processTopicChapterInsideFlow by replacing

<xsl:apply-templates select="." mode="processTopicChapterInsideFlow"/>

with

<fo:page-sequence
    master-reference="{if (@outputclass) then (concat(@outputclass, '-sequence')) else 'body-sequence'}"
    xsl:use-attribute-sets="page-sequence.body">
    <xsl:call-template name="startPageNumbering"/>
    <xsl:call-template name="insertBodyStaticContents"/>
    <fo:flow flow-name="xsl-region-body">
        <fo:block xsl:use-attribute-sets="topic">
            <xsl:call-template name="commonattributes"/>
            <xsl:variable name="level" as="xs:integer">
                <xsl:apply-templates select="." mode="get-topic-level"/>
            </xsl:variable>
            <xsl:if test="$level eq 1">
                <fo:marker marker-class-name="current-topic-number">
                    <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:apply-templates select="." mode="insertTopicHeaderMarker"/>
            </xsl:if>

            <xsl:apply-templates select="*[contains(@class,' topic/prolog ')]"/>

            <xsl:apply-templates select="." mode="insertChapterFirstpageStaticContent">
                <xsl:with-param name="type" select="'chapter'"/>
            </xsl:apply-templates>

            <fo:block xsl:use-attribute-sets="topic.title">
                <xsl:call-template name="pullPrologIndexTerms"/>
                <xsl:for-each select="*[contains(@class,' topic/title ')]">
                    <xsl:apply-templates select="." mode="getTitle"/>
                </xsl:for-each>
            </fo:block>

            <xsl:choose>
                <xsl:when test="$chapterLayout='BASIC'">
                    <xsl:apply-templates select="*[not(contains(@class, ' topic/topic ') or contains(@class, ' topic/title ') or
                        contains(@class, ' topic/prolog '))]"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates select="." mode="createMiniToc"/>
                </xsl:otherwise>
            </xsl:choose>

            <xsl:apply-templates select="*[contains(@class,' topic/topic ')]"/>
            <xsl:call-template name="pullPrologIndexTerms.end-range"/>
        </fo:block>
    </fo:flow>
</fo:page-sequence>
raducoravu commented 3 years ago

Thanks @xephon2 we are not interested that much in XSL-FO based customizations any more having invested in CSS based PDF publishing which makes it very easy to change the layout on any DITA element. But I will leave this issue opened, maybe others are interested in your fix details. Or you can open a pull request.