/// <summary> /// Assigns the object that will handle all the error events. /// </summary> /// <param name="handler">The object that handles the errors events.</param> public virtual void setErrorHandler(XmlSaxErrorHandler handler) { if (handler != null) this.errorHandler = handler; else throw new System.Xml.XmlException("Error assigning the Error handler: a null Error Handler was received"); }
/// <summary> /// Public constructor for the class. /// </summary> public XmlSAXDocumentManager() { isValidating = false; namespaceAllowed = false; reader = null; callBackHandler = null; errorHandler = null; locator = null; lexical = null; entityResolver = null; parserFileName = ""; }
/// <summary> /// Parses the specified stream and process the events over the specified handler, and resolves the /// entities with the specified URI. /// </summary> /// <param name="stream">The stream with the XML.</param> /// <param name="handler">The handler that manage the parser events.</param> /// <param name="URI">The namespace URI for resolve external etities.</param> public virtual void parse(System.IO.Stream stream, XmlSaxContentHandler handler, System.String URI) { try { if (handler is XmlSaxDefaultHandler) { this.errorHandler = (XmlSaxDefaultHandler) handler; this.entityResolver = (XmlSaxDefaultHandler) handler; } if (!(this is XmlSaxParserAdapter)) this.callBackHandler = handler; else { if(this.callBackHandler == null) this.callBackHandler = handler; } System.Xml.XmlTextReader tempTextReader = new System.Xml.XmlTextReader(URI, stream); System.Xml.XmlValidatingReader tempValidatingReader = new System.Xml.XmlValidatingReader(tempTextReader); parserFileName = null; tempValidatingReader.ValidationType = (this.isValidating) ? System.Xml.ValidationType.DTD : System.Xml.ValidationType.None; tempValidatingReader.ValidationEventHandler += new System.Xml.Schema.ValidationEventHandler(this.ValidationEventHandle); this.reader = tempValidatingReader; this.DoParsing(); } catch (System.Xml.XmlException e) { if (this.errorHandler != null) this.errorHandler.fatalError(e); throw e; } }
public virtual JDFDoc parseInputSource(XmlSourceSupport inSource, string schemaLocation, string documentClassName, XmlSaxErrorHandler errorHandler, bool bEraseEmpty, bool bDoNamespaces) { JDFDoc doc = null; if (errorHandler is XMLErrorHandler) { initParser(schemaLocation, documentClassName); } else { initParser(schemaLocation, documentClassName); } doc = runParser(inSource, bEraseEmpty); if (doc == null) { // this is the error case: if (!bDoNamespaces) { // try again, ignoring name spaces setIgnoreNamespace(false); doc = runParser(inSource, bEraseEmpty); } } return(doc); }