Need to retrieve and display data associated with SAX Parse error
Hello!
Is there a way that i can enhance the data displayed in a typical SAX parsing error message, like get some of the addional field data on the record in error?
Reason being, i am piping the XML directly into the SAXParse and don't have access to the XML after it's been sent the parser, plus, i dealing with billion row files!
I was thinking about modifying the XMLSchemaValidator, but just figuring out how to re-compile it would be a big challenge!
error:
setValidity:
Error number : 1
Error starts on line number : 14203
Error starts on column position: 17
Error text is : org.xml.sax.SAXParseException: cvc-enumeration-valid: Value 'xMOLD' is not facet-valid with respect to
enumeration '[DSTR, EXT, MAFR, MASS, MCAP, MODN, MOLD, MR, NAR, PLUS, PWO, SPEC, WO]'. It must be a value from the enumeration.
Error public id : null
Error system id : null
error:
setValidity:
Error number : 2
Error starts on line number : 14203
Error starts on column position: 17
Error text is : org.xml.sax.SAXParseException: cvc-type.3.1.3: The value 'xMOLD' of element 'CODE_RSLTN' is not valid.
Error public id : null
Error system id : null
--------------------------------------------------------------------------------------------------
Sample code from XMLSchemaValidator:
import org.apache.xerces.xni.parser.XMLDocumentSource;
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLInputSource;
import org.apache.xerces.xs.AttributePSVI;
import org.apache.xerces.xs.ElementPSVI;
/**
* The XML Schema validator. The validator implements a document
* filter: receiving document events from the scanner; validating
* the content and structure; augmenting the InfoSet, if applicable;
* and notifying the parser of the information resulting from the
* validation process.
* <p>
* This component requires the following features and properties from the
* component manager that uses it:
* <ul>
* <li>http://xml.org/sax/features/validation</li>
* <li>http://apache.org/xml/properties/internal/symbol-table</li>
* <li>http://apache.org/xml/properties/internal/error-reporter</li>
* <li>http://apache.org/xml/properties/internal/entity-resolver</li>
* </ul>
*
* @author Sandy Gao IBM
* @author Elena Litani IBM
* @author Andy Clark IBM
* @author Neeraj Bajaj, Sun Microsystems, inc.
* @version $Id: XMLSchemaValidator.java,v 1.151 2004/02/10 21:26:03 kohsuke Exp $
*/
public class XMLSchemaValidator
implements XMLComponent, XMLDocumentFilter, FieldActivator, RevalidationHandler {
//
// Constants
//
private static final boolean DEBUG = false;
// feature identifiers
/** Feature identifier: validation. */
protected static final String VALIDATION =
Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;