コード例 #1
0
		/// <summary>
		/// Assigns the object that will handle all the content events.
		/// </summary>
		/// <param name="handler">The object that handles the content events.</param>
		public virtual void setContentHandler(XmlSaxContentHandler handler)
		{
			if (handler != null)
				this.callBackHandler = handler;
			else
				throw new System.Xml.XmlException("Error assigning the Content handler: a null Content Handler was received");
		}
コード例 #2
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;
			}
		}
コード例 #3
0
		/// <summary>
		/// Parses the specified 'XmlSourceSupport' instance and process the events over the specified handler, 
		/// and resolves the entities with the specified URI.
		/// </summary>
		/// <param name="source">The 'XmlSourceSupport' that contains the XML.</param>
		/// <param name="handler">The handler that manages the parser events.</param>
		public virtual void parse(XmlSourceSupport source, XmlSaxContentHandler handler)
		{
			if (source.Characters != null)
				parse(source.Characters.BaseStream, handler);
			else
			{
				if (source.Bytes != null)
					parse(source.Bytes, handler);
				else
				{
					if(source.Uri != null)
						parse(source.Uri, handler);
					else
						throw new System.Xml.XmlException("The XmlSource class can't be null");
				}
			}
		}
コード例 #4
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 = "";
		}