コード例 #1
0
		/// <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;
			}
		}
コード例 #2
0
		/// <summary>
		/// Allows an application to register an entity resolver.
		/// </summary>
		/// <param name="resolver">The entity resolver.</param>
		public virtual void setEntityResolver(XmlSaxEntityResolver resolver)
		{
			this.entityResolver = resolver;
		}
コード例 #3
0
		/// <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 = "";
		}