dita-community / org.dita-community.split-page-sequences

Open Toolkit plug-in to split XSL-FO page sequences below the chapter level
Apache License 2.0
1 stars 1 forks source link

Text Lost In Some Contexts #9

Open rajko-furlan opened 3 months ago

rajko-furlan commented 3 months ago

When an fo:block contains mixed content, the text can be lost. Consider the following XML snippet:

<fo:block>Some text<fo:list-block>...

The text "Some text" will be dropped.

To fix this issue the in following template in split-page-sequences.xsl

<xsl:template match="node()" mode="sps:split-flow" priority="1">
    <xsl:param name="doDebug" as="xs:boolean" tunnel="yes" select="false()"/>    
    <xsl:param name="restricted-to" as="node()+" tunnel="yes"/>

    <xsl:if test="exists(. intersect $restricted-to)">
        <xsl:next-match/>
    </xsl:if>
</xsl:template>

Should be changed to <xsl:if test="exists(. intersect $restricted-to) or self:text()">

That's because given how restricted-to is created exists(. intersect $restricted-to) may not pass for text nodes. In alternative, the could be changed to

<xsl:if test="exists(. intersect $restricted-to) or (self::text() and exists(.. intersect $restricted-to))">

to make it more restrictive, but I believe the additional exists is not necessary. It won't harm though :)

stefan-jung commented 3 months ago

@rajko-furlan and @contrext , the suggested fix partially works, but still we have issues on inline elements. We'll investigate this further.

stefan-jung commented 3 months ago

@rajko-furlan, @contrext, the line should be changed to:

<xsl:if test="exists(. intersect $restricted-to) or ((self::text() or self::fo:inline) and exists(ancestor::fo:block[1] intersect $restricted-to))">

All kudos go to @rajko-furlan, I am just the messenger.

stefan-jung commented 3 months ago

I've submitted the PR https://github.com/dita-community/org.dita-community.split-page-sequences/pull/10