Can XHTML fragments be specified directly in a template *.opt file?

Are you missing a feature? Request its implementation here.
chrispitude
Posts: 529
Joined: Thu May 02, 2019 2:32 pm

Can XHTML fragments be specified directly in a template *.opt file?

Post by chrispitude »

When I set an XHTML fragment parameter in a DITA-OT project file:

Code: Select all

        <publication transtype="webhelp-responsive">
            <param name="webhelp.fragment.head" value="&lt;p&gt;HELLO&lt;p&gt;"/>
        </publication>
it works as expected. But when I set it in a template *.opt file:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<publishing-template>
    <name>Synopsys WebHelp</name>
    <webhelp>
        <parameters>
            <parameter name="webhelp.fragment.head" value="&lt;p&gt;HELLO&lt;p&gt;"/>
        </parameters>
        <resources>
            <css file="empty.css"/>
        </resources>
    </webhelp>
</publishing-template>
then I get an error that the fragment is not well-formed:

Code: Select all

$ dita -i map.ditamap -f webhelp-responsive -Dwebhelp.publishing.template="template"
     [echo] Oxygen XML WebHelp 25.0 build 2022060718
[templatetask] [Fatal Error] :1:12: XML document structures must start and end within the same entity.
[templatetask] HTML Fragment with ID 'webhelp.fragment.head' is not XML well-formed.
[templatetask] Reason: XML document structures must start and end within the same entity.
     [echo] Load file from temp: /tmp/temp20220613200458916
     [echo] Indexer language=en
     [echo] Copying custom template resources. Ant file: /tmp/temp20220613200458916/wh-template-copy-resources.xml
     [echo] Indexing html files in /mnt/c/nobackup/webhelp_fragment_in_template/./out, indexer language is: en
Is this expected?

Testcase:
webhelp_fragment_in_template.zip
(2.59 KiB) Downloaded 7 times
alin
Site Admin
Posts: 221
Joined: Thu Dec 24, 2009 11:21 am

Re: Can XHTML fragments be specified directly in a template *.opt file?

Post by alin »

Hello Chris,

I have tested your scenario and although the transformation log contains some errors, the transformation runs successfully and the output is as expected. It contains the provided HTML fragment.

The WebHelp Responsive transfromation requires that the provided HTML fragments are XML well-formed in order for the internal XSL stylesheets to be able to process them. This requirement is listed in our User Manual.
However, starting with version 23.1, Oxygen WebHelp has intrduced a built-in mechanism that tries to automatically convert ill-formed HTML fragments to well-formed XML.

During the WebHelp transformation each HTML fragment is validated against the XML well-formedness rules and any validation errors are reported in the transformation log. These are the errors you are seeing in the console output of your transformation.
If an HTML fragment is not well-formed, WebHelp Responsive tries to convert it and writes the converted content into a temporary XML file.

If you run your transformation in verbose mode (using the -v argument) you will see the following content in the console output of your transformation:

Code: Select all

[templatetask] [Fatal Error] :1:12: XML document structures must start and end within the same entity.
[templatetask] HTML Fragment with ID 'webhelp.fragment.head' is not XML well-formed.
[templatetask] Reason: XML document structures must start and end within the same entity.
[templatetask] Creating file C:\Users\ALIN_B~1\AppData\Local\Temp\temp20220620170103044\whr-html-fragments\webhelp_fragment_head.xml for fragment webhelp.fragment.head. Created: true
[templatetask] 'webhelp.fragment.head' -> C:\Users\ALIN_B~1\AppData\Local\Temp\temp20220620170103044\whr-html-fragments\webhelp_fragment_head.xml
[templatetask] Set ANT property: 'webhelp.fragment.head' -> C:\Users\ALIN_B~1\AppData\Local\Temp\temp20220620170103044\whr-html-fragments\webhelp_fragment_head.xml
We will check to see why the console output of the transformation is not complete when not running the transformation in verbose mode.


Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply