Menu

#15 Highlighting crashes on XML snippet

2.x
open
nobody
None
5
2019-10-01
2019-09-30
Jirka Kosek
No

Attempt to highlight the following incomplete fragment of XML

<xsl:for-each-group select =

fails with the following:

java.lang.StringIndexOutOfBoundsException: String index out of range: 28
at java.lang.String.charAt(Unknown Source)
at net.sf.xslthl.CharIter.current(CharIter.java:151)
at net.sf.xslthl.highlighters.XMLHighlighter.readTagContent(XMLHighlight
er.java:189)
at net.sf.xslthl.highlighters.XMLHighlighter.highlight(XMLHighlighter.ja
va:341)
at net.sf.xslthl.MainHighlighter.highlight(MainHighlighter.java:146)

Discussion

  • Radu Coravu

    Radu Coravu - 2019-10-01

    @kosek I added a fix for the issue + test case.

     
  • cleversoft

    cleversoft - 2019-10-01

    Thanks for resolving the issue. However the problem still persists. I just checked out current trunk revision 167 having no luck using it. Consider the following snippet:

    <section version="5.1" xmlns="http://docbook.org/ns/docbook">
      <title/>
      <programlisting language="java">@<emphasis role="bold">Test</emphasis></programlisting>
    </section>
    

    The@language attribute refers to Docbook highlighting distribution's sub directory included into the transformation by xslthl-config.xml. The related transformation fails:

    > java -cp "/usr/share/hdm-docbook-xsl/docbook-xsl/extensions/saxon65.jar:/usr/share/hdm-docbook-xsl/docbook-xsl/tools/lib/saxon.jar:/home/goik/xslthl-code/xslthl/target/xslthl-2.1.4-SNAPSHOT.jar" '-Dxslthl.config=file:///usr/share/hdm-docbook-xsl/docbook-xsl/highlighting/xslthl-config.xml' com.icl.saxon.StyleSheet test.xml /usr/share/xmlmind/addon/config/docbook5/xsl/webhelp/webhelp.xsl  highlight.source=1
    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:114)
        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)
        at com.icl.saxon.expr.NodeListExpression.enumerate(NodeListExpression.java:79)
        at com.icl.saxon.Controller.applyTemplates(Controller.java:248)
        at com.icl.saxon.style.XSLApplyTemplates.process(XSLApplyTemplates.java:139)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLWhen.process(XSLWhen.java:72)
        at com.icl.saxon.style.XSLChoose.process(XSLChoose.java:96)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLWhen.process(XSLWhen.java:72)
        at com.icl.saxon.style.XSLChoose.process(XSLChoose.java:96)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLWhen.process(XSLWhen.java:72)
        at com.icl.saxon.style.XSLChoose.process(XSLChoose.java:96)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLTemplate.expand(XSLTemplate.java:229)
        at com.icl.saxon.style.XSLCallTemplate.process(XSLCallTemplate.java:203)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLWhen.process(XSLWhen.java:72)
        at com.icl.saxon.style.XSLChoose.process(XSLChoose.java:96)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLElement.process(XSLElement.java:142)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLOtherwise.process(XSLOtherwise.java:48)
        at com.icl.saxon.style.XSLChoose.process(XSLChoose.java:96)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLTemplate.expand(XSLTemplate.java:229)
        at com.icl.saxon.style.XSLTemplate.start(XSLTemplate.java:202)
        at com.icl.saxon.Controller.applyTemplates(Controller.java:288)
        at com.icl.saxon.style.XSLApplyTemplates.process(XSLApplyTemplates.java:139)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLElement.process(XSLElement.java:142)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLTemplate.expand(XSLTemplate.java:229)
        at com.icl.saxon.style.XSLTemplate.start(XSLTemplate.java:202)
        at com.icl.saxon.Controller.applyImports(Controller.java:340)
        at com.icl.saxon.style.XSLApplyImports.process(XSLApplyImports.java:68)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLGeneralVariable.getSelectValue(XSLGeneralVariable.java:238)
        at com.icl.saxon.style.XSLParam.process(XSLParam.java:76)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLTemplate.expand(XSLTemplate.java:229)
        at com.icl.saxon.style.XSLCallTemplate.process(XSLCallTemplate.java:203)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLWhen.process(XSLWhen.java:72)
        at com.icl.saxon.style.XSLChoose.process(XSLChoose.java:96)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLTemplate.expand(XSLTemplate.java:229)
        at com.icl.saxon.style.XSLTemplate.start(XSLTemplate.java:202)
        at com.icl.saxon.Controller.applyTemplates(Controller.java:288)
        at com.icl.saxon.style.XSLApplyTemplates.process(XSLApplyTemplates.java:139)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLTemplate.expand(XSLTemplate.java:229)
        at com.icl.saxon.style.XSLTemplate.start(XSLTemplate.java:202)
        at com.icl.saxon.Controller.applyTemplates(Controller.java:297)
        at com.icl.saxon.Controller.defaultAction(Controller.java:313)
        at com.icl.saxon.Controller.applyTemplates(Controller.java:278)
        at com.icl.saxon.style.XSLApplyTemplates.process(XSLApplyTemplates.java:139)
        at com.icl.saxon.style.StyleElement.processChildren(StyleElement.java:643)
        at com.icl.saxon.style.XSLTemplate.expand(XSLTemplate.java:229)
        at com.icl.saxon.style.XSLTemplate.start(XSLTemplate.java:202)
        at com.icl.saxon.Controller.applyTemplates(Controller.java:297)
        at com.icl.saxon.Controller.run(Controller.java:220)
        at com.icl.saxon.Controller.transformDocument(Controller.java:1125)
        at com.icl.saxon.Controller.transform(Controller.java:994)
        at com.icl.saxon.StyleSheet.processFile(StyleSheet.java:508)
        at com.icl.saxon.StyleSheet.doMain(StyleSheet.java:330)
        at com.icl.saxon.StyleSheet.main(StyleSheet.java:47)
    
     
  • Radu Coravu

    Radu Coravu - 2019-10-01

    You seem to have added a separate issue for your unhandled exception and it is not related with this current issue:

    https://sourceforge.net/p/xslthl/bugs/14/

    I comitted a fix also for that issue, but I did not look at your attached patch, if you have another idea about how to make this work maybe we can talk on that issue.

     

Log in to post a comment.