AntennaHouse / pdf5-ml

Antenna House PDF5-ML DITA-OT Plug-in
23 stars 9 forks source link

Build failure for element without @xtrf #16

Closed robander closed 7 years ago

robander commented 7 years ago

This is probably an edge case, but took me a bit to track down.

I've got a plug-in that introduces elements during pre-processing. It converts some markup to an <object> element for use later on. Because they are generated in the middle of preprocess, they don't get an @xtrf attribute.

When the pdf5.ml transform runs, it hits this rule for the <object> element: https://github.com/AntennaHouse/pdf5-ml/blob/master/com.antennahouse.pdf5.ml/xsl/dita2fo_bodyelements.xsl#L1207

<xsl:template match="*[contains(@class, ' topic/object ')]">
        <xsl:call-template name="warningContinue">
            <xsl:with-param name="prmMes">
                <xsl:value-of select="ahf:replace($stMes041,('%file','%class'),(@xtrf,@classid))"/>
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

This crashes the build because of the missing @xtrf attribute:

     [xslt] C:\dita-ot-2.3.1\plugins\com.antennahouse.pdf5.ml\xsl\dita2fo_util.xsl:193: 
 Fatal Error! An empty sequence is not allowed as the third argument of ahf:replace()
     [xslt] Failed to process C:\dita-ot-2.3.1\temp\sample_en_CONVERTED.xml
Error: The following error occurred while executing this line:
C:\dita-ot-2.3.1\plugins\com.antennahouse.pdf5.ml\build.xml:190:
 The following error occurred while executing this line:
C:\dita-ot-2.3.1\plugins\com.antennahouse.pdf5.ml\build_transform.xml:41:
 The following error occurred while executing this line:
C:\dita-ot-2.3.1\plugins\com.antennahouse.pdf5.ml\build_transform.xml:77:
 The following error occurred while executing this line:
C:\dita-ot-2.3.1\plugins\com.antennahouse.pdf5.ml\build_transform.xml:90:
 The following error occurred while executing this line:
C:\dita-ot-2.3.1\plugins\com.antennahouse.pdf5.ml\build_transform.xml:105:
 Fatal error during transformation using 
 C:\dita-ot-2.3.1\plugins\com.antennahouse.pdf5.ml\xsl\dita2fo_shell.xsl: 
 An empty sequence is not allowed as the third argument of ahf:replace(); SystemID: 
 file:/C:/dita-ot-2.3.1/plugins/com.antennahouse.pdf5.ml/xsl/dita2fo_util.xsl; Line#: 193; Column#: -1

I realize this is an edge case, but it's also possible (with a configuration option) to skip generating @xtrf for all elements. This can help optimize the build for some scenarios. If using that option, I would run into the same issue. The build should probably not assume that @xtrf is specified in all cases, or at least provide a more graceful failure. For details on the option, see "generate-debug-attribute" http://www.dita-ot.org/dev/parameters/parameters-base.html#base__generate-debug-attributes

ToshihikoMakita commented 7 years ago

The build should probably not assume that @xtrf is specified in all cases

Thank you for pointing out. I will fix this problem as soon as possible.