Handling XML Tree Exceptions

An exception is raised when an error is detected while processing an XML document. The exception is an instance of the JadeXMLException class.

For well-formed parsing errors, the line number and column number of the error is reported. For example, the following methods check that an XML document file is well-formed.

check(fileName: String);
vars
    doc : JadeXMLDocument;
begin
    on JadeXMLException do checkExceptionHandler(exception);
    create doc;
    doc.parseFile(fileName);
    write fileName & ' is well-formed';
    delete doc;
end;

checkExceptionHandler(ex: JadeXMLException):  Integer;
begin
    write ex.fileName & ' is not well-formed - ' & ex.extendedErrorText &
             ' at line ' & ex.lineNumber.String & ', column ' &
             ex.columnNumber.String & ': ' & ex.errorItem;
    return Ex_Abort_Action;
end;

If the document is not well-formed, an XML exception is raised and the checkExceptionHandler method in the above example is invoked to print the error details.