greenstone.org greenstone wiki greenstone trac planet greenstone

Changeset 16331

Show
Ignore:
Timestamp:
2008-07-10 12:56:42 (3 months ago)
Author:
ak19
Message:

Fixed a bug in showXMLParseFailureLine() and it now informs the debugger when there's a newline or empty space before the start of the xml tags (this won't be clear from the erroneous line that's printed out, since that line will be empty.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gli/trunk/src/org/greenstone/gatherer/util/XMLTools.java

    r15581 r16331  
    493493     */ 
    494494    public static void showXMLParseFailureLine(SAXParseException e, String xmlContents) { 
     495         
     496        // There should be no characters at all that preceed the <?xml>... bit.  
     497        // The first check is for starting spaces: 
     498        if(xmlContents.startsWith("\n") || xmlContents.startsWith(" ") || xmlContents.startsWith("\t")) { 
     499            DebugStream.println("ERROR: illegal start of XML. Space/tab/newline should not preceed xml declaration.\n"); 
     500            DebugStream.println("xmlContents (length is " + xmlContents.length() + "):\n" + xmlContents); 
     501            return; // nothing more to do, first error identified 
     502        } 
     503 
    495504        // the actual line (String literal) where parsing failed and the SAXParseException occurred. 
    496505        String line = ""; 
     
    504513                for(int i = 1; i <= linenumber; i++) { 
    505514                    end = xmlContents.indexOf("\n"); 
    506                     line = xmlContents.substring(start, end); 
     515                    if(end > 0) { 
     516                        line = xmlContents.substring(start, end); 
     517                    } 
    507518                    start = end+1; 
    508519                }