Consider a docbook 5.0 file test.xml:
<section version="5.0" xmlns="http://docbook.org/ns/docbook">
<title>Xslthl problem</title>
<programlisting language="java">@<emphasis role="bold"/></programlisting>
</section>
XSLT being executed as:
goik@hopc Test> java -cp "/usr/share/hdm-docbook-xsl/docbook-xsl/extensions/saxon65.jar:\
/usr/share/hdm-docbook-xsl/docbook-xsl/tools/lib/saxon.jar:/usr/share/hdm-docbook-xsl/lib/xslthl-2.1.3.jar" \
'-Dxslthl.config=file:///usr/share/hdm-docbook-xsl/docbook-xsl/highlighting/xslthl-config.xml' \
com.icl.saxon.StyleSheet test.xml /usr/share/hdm-docbook-xsl/CustomLayer/webhelp/webhelpHL.xsl \ highlight.source=1
The XSL webhelpHL.xsl has been modified from stock webhelp.xsl to support highlighting:
<xsl:import href="../../docbook-xsl/xhtml/chunk.xsl"/>
<xsl:import href="../../docbook-xsl/xhtml/highlight.xsl"/>
<xsl:import href="../../docbook-xsl/webhelp/xsl/webhelp-common.xsl"/>
<xsl:import href="../../docbook-xsl/webhelp/xsl/titlepage.templates.xsl"/>
This yields:
language: en
java.lang.NullPointerException
at net.sf.xslthl.highlighters.AnnotationHighlighter.startsWith(AnnotationHighlighter.java:67)
at net.sf.xslthl.MainHighlighter.highlight(MainHighlighter.java:100)
at net.sf.xslthl.ConnectorSaxon6.highlight(ConnectorSaxon6.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.icl.saxon.expr.FunctionProxy.call(FunctionProxy.java:586)
at com.icl.saxon.expr.FunctionProxy.enumerate(FunctionProxy.java:466)
...
N.B.: The docbook example in question is a condensed version of real Java code trying to serve a simple example.
My system: Saxon 6.5.5, current Java 1.8, stock Docbook XSL stylesheets.
Proposal: Since Exceptions are inevetable they should be caught inside xsltHL being a plugin to the XSLT processor thereby issuing a warning. The transformation process should continue.
In my setting the XSLT silently dies during the process instead of issuing a warning and continue with the remaining code. And without a file position indication debugging is pretty tough.
I've created a quick hack, see attached patch. Basic idea: