From: Keats <ke...@ea...> - 2003-08-05 20:08:45
|
Marc, I have isolated this problem and it appears to be a whitespace issue with the in-line explicit #begin. I reduced your test case to the minimal: #if (true) #begin #set $x=0 #end which still gives the error. Adding a second space before the #set (or replacing it with a newline) makes the error go away. Apparently the parser prematurely discards the whitespace that it needs to recognize the next token as a directive. I have made a one-line patch to the ParserBlockBuilder.directiveOK(), line 227, to check for an empty String which seems to fix the problem. All the unit tests still pass, but I guess I'd feel more confortable having Brian bless this before I commit the change. Keats ----- Original Message ----- From: "Marc Palmer" <ma...@an...> To: <web...@li...> Sent: Friday, August 01, 2003 7:12 AM Subject: [Webmacro-devel] Parser error: StringIndexOutOfRange > > I just got, using the latest CVS source: > > org.webmacro.engine.BuildException: Error parsing template: > FileTemplate:xxxxxx (name removed) > java.lang.StringIndexOutOfBoundsException: String index out of range: -1 > > The problem seems to be related to #begin...#end handling, possibly to do > with nested directives (#set). > > If I remove my EXPLICIT #begin...#end it works fine. > > The line is marked in the template below. I will add a test case for this. > > > #include "includes/header.wmt" > > <h2>Generator for SQL CREATE TABLE based on Metalizer Schema</h2> > > <form action="gensql.wmt" method="post"> > Schema name: <input name="$Ignition.FormFieldName.schemaName" > #if ($Ignition.FieldValue.schemaName) > value="$Ignition.FieldValue.schemaName" > #end > > > <input type="submit" value=" Generate "> > </form> > > #if ($Ignition.FieldValue.schemaName) > <h3>SQL follows:</h3> > > #set $schema = $Ignition.getSchema($Ignition.FieldValue.schemaName) > <pre> > CREATE TABLE tablename ( > > #set $first = true > #foreach $group in $schema.FieldGroups > #begin > #foreach $fieldName in $schema.getFieldNamesInGroup($group) > #begin > #set $field = $schema.getField($fieldName) > !!!!!!!!!!!! This next line is the problem > #if ($first) #begin #set $first = false #end #else #begin , #end > $field.Name $field.DataType.Name > #end > #end > ); > </pre> > > #end > |