donHenaro
donHenaro

Reputation: 1

How to save xml comments like <!--pagebreak--> when converting dita file to docx (with com.elovirta.ooxml v.1.4)

I use: Dita open toolkit 3.7.4, plugin com.elovirta.ooxml, java 17. I have such dita file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="_1.0">
    <title>Title</title>
    <body>
        <p>First</p>
        <!--pagebreak-->
        <p>Second</p>
        <p>Third</p>
    </body>
</topic>

Under standard conditions, the comment (<!--pagebreak-->) disappears during conversion.

I have added a handler file pagebreaks.xsl with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
  <xsl:template match="comment()">
    <xsl:copy-of select="."/>
  </xsl:template>
</xsl:stylesheet>

and added a link to it in document.xsl:

...  
<xsl:import href="pagebreaks.xsl"/>
<xsl:import href="document.utils.xsl"/>
...

However, that doesn't work either.

Tell me how to save xml comments during conversion in docx file?

It is expected that the output is something like this document.xml content in a docx file

...
        <w:p>
            <w:pPr>
                <w:pStyle w:val="BodyText"/>
            </w:pPr>
            <w:r>
                <w:t>First</w:t>
            </w:r>
        </w:p>
        <!--pagebreak-->
        <w:p>
            <w:pPr>
                <w:pStyle w:val="BodyText"/>
            </w:pPr>
            <w:r>
                <w:t>Second</w:t>
            </w:r>
        </w:p>
        <w:p>
            <w:pPr>
                <w:pStyle w:val="BodyText"/>
            </w:pPr>
            <w:r>
                <w:t>Third</w:t>
            </w:r>
        </w:p>
...

Upvotes: 0

Views: 94

Answers (0)

Related Questions