Exemplo n.º 1
0
 public virtual void Characters(char[] ch, int start, int length)
 {
     if (_contentHandler != null)
     {
         _contentHandler.Characters(ch, start, length);
     }
 }
Exemplo n.º 2
0
 internal void charData(char[] ch, int start, int length)
 {
     contentHandler.Characters(ch, start, length);
 }
Exemplo n.º 3
0
 public virtual void CharData(char[] ch, int start, int length)
 {
     _contentHandler.Characters(ch, start, length);
 }
Exemplo n.º 4
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()