Update of /cvsroot/xdoclet/xdoclet/core/src/xdoclet/template
In directory sc8-pr-cvs1:/tmp/cvs-serv23792/core/src/xdoclet/template

Modified Files:
        TemplateEngine.java XDocletTemplateMessages.java 
Log Message:
fix for the issue XDT-80
Improved error handling in TemplateEngine.extractNextAttribute()



Index: TemplateEngine.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/template/TemplateEngine.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** TemplateEngine.java 8 Sep 2002 12:41:25 -0000       1.30
--- TemplateEngine.java 27 Nov 2002 12:18:13 -0000      1.31
***************
*** 679,751 ****
          char quoteChar = '"';
  
!         // read attribute name
!         while (template.charAt(index) != '=' && 
(!Character.isWhitespace(template.charAt(index)))) {
!             attributeName.append(template.charAt(index));
!             index++;
!         }
! 
!         index = skipWhitespace(template, index);
! 
!         // skip = sign
!         if (template.charAt(index) == '=') {
!             index++;
!         }
!         else {
!             throw new 
TemplateException(Translator.getString(XDocletTemplateMessages.class, 
XDocletTemplateMessages.TEMPLATE_EQUALS_EXPECTED, new 
String[]{Integer.toString(getLineNumber(template, index)), 
getTemplateURL().toString()}));
!         }
! 
!         index = skipWhitespace(template, index);
  
!         // skip " sign
!         if (template.charAt(index) == '"') {
!             index++;
!             quoteChar = '"';
!         }
!         else if (template.charAt(index) == '\'') {
!             index++;
!             quoteChar = '\'';
!         }
!         else {
!             throw new 
TemplateException(Translator.getString(XDocletTemplateMessages.class, 
XDocletTemplateMessages.TEMPLATE_QUOTE_EXPECTED, new 
String[]{Integer.toString(getLineNumber(template, index)), 
getTemplateURL().toString()}));
!         }
  
!         // read attribute value
!         while (template.charAt(index) != quoteChar) {
!             attributeValue.append(template.charAt(index));
!             index++;
!         }
  
!         // skip " sign
!         index++;
!         tagContext.setHasMoreAttributes(true);
  
!         if (attributeValue.toString().indexOf(XDOCLET_HEAD) != -1) {
!             attributeValue = new StringBuffer(outputOf(attributeValue.toString()));
!         }
  
!         index = skipWhitespace(template, index);
  
!         if (template.charAt(index) == '>') {
              index++;
!             tagContext.setBlock(true);
!             tagContext.setHasMoreAttributes(false);
  
!             // no more attributes
!         }
!         else if (template.charAt(index) == '/') {
!             index++;
  
              if (template.charAt(index) == '>') {
                  index++;
!                 tagContext.setBlock(false);
                  tagContext.setHasMoreAttributes(false);
  
                  // no more attributes
              }
!             else {
!                 throw new 
TemplateException(Translator.getString(XDocletTemplateMessages.class, 
XDocletTemplateMessages.TEMPLATE_GT_EXPECTED, new 
String[]{Integer.toString(getLineNumber(template, index)), 
getTemplateURL().toString()}));
              }
          }
! 
          attributes.setProperty(attributeName.toString(), attributeValue.toString());
          return index;
--- 679,755 ----
          char quoteChar = '"';
  
!         try {
!             // read attribute name
!             while (template.charAt(index) != '=' && 
(!Character.isWhitespace(template.charAt(index)))) {
!                 attributeName.append(template.charAt(index));
!                 index++;
!             }
  
!             index = skipWhitespace(template, index);
  
!             // skip = sign
!             if (template.charAt(index) == '=') {
!                 index++;
!             }
!             else {
!                 throw new 
TemplateException(Translator.getString(XDocletTemplateMessages.class, 
XDocletTemplateMessages.TEMPLATE_EQUALS_EXPECTED, new 
String[]{Integer.toString(getLineNumber(template, index)), 
getTemplateURL().toString()}));
!             }
  
!             index = skipWhitespace(template, index);
  
!             // skip " sign
!             if (template.charAt(index) == '"') {
!                 index++;
!                 quoteChar = '"';
!             }
!             else if (template.charAt(index) == '\'') {
!                 index++;
!                 quoteChar = '\'';
!             }
!             else {
!                 throw new 
TemplateException(Translator.getString(XDocletTemplateMessages.class, 
XDocletTemplateMessages.TEMPLATE_QUOTE_EXPECTED, new 
String[]{Integer.toString(getLineNumber(template, index)), 
getTemplateURL().toString()}));
!             }
  
!             // read attribute value
!             while (template.charAt(index) != quoteChar) {
!                 attributeValue.append(template.charAt(index));
!                 index++;
!             }
  
!             // skip " sign
              index++;
!             tagContext.setHasMoreAttributes(true);
  
!             if (attributeValue.toString().indexOf(XDOCLET_HEAD) != -1) {
!                 attributeValue = new 
StringBuffer(outputOf(attributeValue.toString()));
!             }
! 
!             index = skipWhitespace(template, index);
  
              if (template.charAt(index) == '>') {
                  index++;
!                 tagContext.setBlock(true);
                  tagContext.setHasMoreAttributes(false);
  
                  // no more attributes
              }
!             else if (template.charAt(index) == '/') {
!                 index++;
! 
!                 if (template.charAt(index) == '>') {
!                     index++;
!                     tagContext.setBlock(false);
!                     tagContext.setHasMoreAttributes(false);
! 
!                     // no more attributes
!                 }
!                 else {
!                     throw new 
TemplateException(Translator.getString(XDocletTemplateMessages.class, 
XDocletTemplateMessages.TEMPLATE_GT_EXPECTED, new 
String[]{Integer.toString(getLineNumber(template, index)), 
getTemplateURL().toString()}));
!                 }
              }
          }
!         catch (java.lang.StringIndexOutOfBoundsException ex) {
!             throw new 
TemplateException(Translator.getString(XDocletTemplateMessages.class, 
XDocletTemplateMessages.TEMPLATE_SYNTAX_ERROR, new 
String[]{Integer.toString(getLineNumber(template, index)), 
getTemplateURL().toString(), template}));
!         }
          attributes.setProperty(attributeName.toString(), attributeValue.toString());
          return index;

Index: XDocletTemplateMessages.java
===================================================================
RCS file: 
/cvsroot/xdoclet/xdoclet/core/src/xdoclet/template/XDocletTemplateMessages.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** XDocletTemplateMessages.java        28 Jul 2002 22:51:59 -0000      1.2
--- XDocletTemplateMessages.java        27 Nov 2002 12:18:13 -0000      1.3
***************
*** 100,102 ****
--- 100,108 ----
       */
      public final static String TEMPLATE_PARAMETER_MISSING = 
"TEMPLATE_PARAMETER_MISSING";
+ 
+     /**
+      * @msg.bundle   msg="Error in template file: syntax error, line={0} of template 
+file: {1} affecting template: {2}"
+      */
+     public final static String TEMPLATE_SYNTAX_ERROR = "TEMPLATE_SYNTAX_ERROR";
+ 
  }



-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T 
handheld. Power & Color in a compact size! 
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to