Example #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(IXmlSaxContentHandler handler)
 {
     if (handler != null)
         this.callBackHandler = handler;
     else
         throw new System.Xml.XmlException("Error assigning the Content handler: a null Content Handler was received");
 }
Example #2
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, IXmlSaxContentHandler 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");
         }
     }
 }
Example #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 = "";
 }
Example #4
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, IXmlSaxContentHandler 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;
         }
         this.reader = CreateXmlReader(stream, URI);
         this.DoParsing();
     }
     catch (System.Xml.XmlException e)
     {
         if (this.errorHandler != null)
             this.errorHandler.fatalError(e);
         throw e;
     }
 }
Example #5
0
		/// <summary>
		/// Parses the specified stream and process the events over the specified handler.
		/// </summary>
		/// <param name="stream">The stream with the XML.</param>
		/// <param name="handler">The handler that manage the parser events.</param>
		public virtual void parse(Stream stream, IXmlSaxContentHandler handler)
		{
			try
			{
				if (handler is XmlSaxDefaultHandler)
				{
					errorHandler = (XmlSaxDefaultHandler) handler;
					entityResolver = (XmlSaxDefaultHandler) handler;
				}
				if (!(this is XmlSaxParserAdapter))
					callBackHandler = handler;
				else
				{
					if (callBackHandler == null)
						callBackHandler = handler;
				}
				reader = CreateXmlReader(stream);
				DoParsing();
			}
			catch (XmlException e)
			{
				if (errorHandler != null)
					errorHandler.fatalError(e);
				throw e;
			}
		}