Menu

#35 Bug with template parsing...

open
nobody
Print (30)
7
2010-06-16
2010-06-16
Tom
No

I believe I have identified a bug with the print module when the template contains the text "_procedure_". The absolute minimum test case I can reduce this to is the following XML

<document size="A4">
<table columns="1">
<table-row>
<cell>
<anchor reference="http://www.google.com/">_procedure_something.pdf</anchor>
</cell>
</table-row>
</table>
</document>

Converting this from XML to PDF in the standard way gives the following exception

java.lang.ArrayIndexOutOfBoundsException: 24
at org.ujac.util.template.ProcedureToken.initialize(ProcedureToken.java:91)
at org.ujac.util.template.DefaultTemplateInterpreter.parse(DefaultTemplateInterpreter.java:149)
at org.ujac.util.template.DefaultTemplateInterpreter.parse(DefaultTemplateInterpreter.java:86)
at org.ujac.util.template.DefaultTemplateInterpreter.parse(DefaultTemplateInterpreter.java:70)
at org.ujac.util.template.DefaultTemplateInterpreter.execute(DefaultTemplateInterpreter.java:232)
at org.ujac.print.DocumentHandler.executeTemplate(DocumentHandler.java:1140)
at org.ujac.print.tag.AnchorTag.closeItem(AnchorTag.java:130)
at org.ujac.print.DocumentHandler.endElement(DocumentHandler.java:2158)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at org.ujac.print.DocumentPrinter.printDocument(DocumentPrinter.java:626)
at org.ujac.print.DocumentPrinter.printDocument(DocumentPrinter.java:500)
at org.ujac.print.DocumentPrinter.printDocument(DocumentPrinter.java:480)
at test.FileConverter.convert(FileConverter.java:26)
at test.FileConverter.main(FileConverter.java:37)

I'm guessing this is caused by the fact that you can register procedures with template interpreter using the syntax _procedure_

If you need any additional information, please feel free to contact me

Ignoring this bug: great work on this product guys....

Discussion

  • Tom

    Tom - 2010-06-16

    For a workaround in the mean time, see the suggestion here

    https://sourceforge.net/projects/ujac/forums/forum/255347/topic/3742859

    Haven't tested it yet, but it seems like it would work as long as you don't need the use of procedures in the template. A nice enhancement might be to allow you to change these tokens without creating a new template interpreter using syntax similar to...

    DocumentPrinter docprinter = new DocumentPrinter( ---normal stuff here--- );
    docprinter.getTemplateInterpreter().setTokenTypes(new HashMap());

    The advantage of this is that you could turn off template interpreting for certain tokens easily for performance reasons i.e. if not using any of the tokens in your print template you could turn them all off and thus have less overhead in the parsing.

     
  • Tom

    Tom - 2010-06-16
    • priority: 5 --> 7
     

Log in to post a comment.