Changeset 16331


Ignore:
Timestamp:
2008-07-10T12:56:42+12:00 (16 years 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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        }
Note: See TracChangeset for help on using the changeset viewer.