Beispiel #1
0
 public virtual void IgnorableWhitespace(char[] ch, int start, int length)
 {
     if (_contentHandler != null)
     {
         _contentHandler.IgnorableWhitespace(ch, start, length);
     }
 }
 internal void ignorableWhitespace(char[] ch, int start, int length)
 {
     contentHandler.IgnorableWhitespace(ch, start, length);
 }
Beispiel #3
0
        public virtual void Parse(TextReader text)
        {
            Stack             nsstack      = new Stack();
            Locator           locator      = new Locator();
            SAXParseException saxException = new SAXParseException();
            Attributes        atts         = new Attributes();
            XmlTextReader     reader       = null;

            try
            {
                reader = new XmlTextReader(text);
                object nsuri = reader.NameTable.Add(
                    "http://www.w3.org/2000/xmlns/");
                handler.StartDocument();
                while (reader.Read())
                {
                    string prefix = "";
                    locator.LineNumber   = reader.LineNumber;
                    locator.ColumnNumber = reader.LinePosition;
                    handler.SetDocumentLocator(locator);
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        nsstack.Push(null);     //marker
                        atts = new Attributes();
                        while (reader.MoveToNextAttribute())
                        {
                            if (reader.NamespaceURI.Equals(nsuri))
                            {
                                prefix = "";
                                if (reader.Prefix == "xmlns")
                                {
                                    prefix = reader.LocalName;
                                }
                                nsstack.Push(prefix);
                                handler.StartPrefixMapping(prefix, reader.Value);
                            }
                            else
                            {
                                atts.AddAttribute(reader.NamespaceURI, reader.Name, reader.Name, reader.GetType().ToString(), reader.Value);
                            }
                        }
                        reader.MoveToElement();
                        Handler.StartElement(reader.NamespaceURI, reader.LocalName, reader.Name, atts);
                        if (reader.IsEmptyElement)
                        {
                            handler.EndElement(reader.NamespaceURI, reader.LocalName, reader.Name);
                        }
                        break;

                    case XmlNodeType.EndElement:
                        handler.EndElement(reader.NamespaceURI, reader.LocalName, reader.Name);
                        while (prefix != null)
                        {
                            handler.EndPrefixMapping(prefix);
                            prefix = (string)nsstack.Pop();
                        }
                        break;

                    case XmlNodeType.Text:
                        handler.Characters(reader.Value.ToCharArray(), 0, reader.Value.Length);
                        break;

                    case XmlNodeType.ProcessingInstruction:
                        handler.ProcessingInstruction(reader.Name, reader.Value);
                        break;

                    case XmlNodeType.Whitespace:
                        char[] whiteSpace = reader.Value.ToCharArray();
                        handler.IgnorableWhitespace(whiteSpace, 0, 1);
                        break;

                    case XmlNodeType.Entity:
                        handler.SkippedEntity(reader.Name);
                        break;
                    }
                } //While
                handler.EndDocument();
            }     //try
            catch (Exception exception)
            {
                saxException.LineNumber = reader.LineNumber;
                saxException.SystemID   = "";
                saxException.setMessage(exception.GetBaseException().ToString());
                errorHandler.Error(saxException);
            }
            finally
            {
                if (reader.ReadState != ReadState.Closed)
                {
                    reader.Close();
                }
            }
        } //parse()