Esempio n. 1
0
        /// <summary>
        /// Starts a font tag
        /// </summary>
        /// <returns>void</returns>
        /// <param name="text">SpannableStringBuilder</param>
        /// <param name="attributes">IAttributes</param>
        static void startFont(SpannableStringBuilder text, IAttributes attributes)
        {
            String color = attributes.GetValue("color");
            String face  = attributes.GetValue("face");

            int len = text.Length();

            text.SetSpan(new Font(color, face), len, len, SpanTypes.MarkMark);
        }
Esempio n. 2
0
 public override void StartElement(string uri, string localName, string qName, IAttributes atts)
 {
     if (inHEAD > 0)
     {
         if ("title".Equals(localName, StringComparison.OrdinalIgnoreCase))
         {
             inTITLE++;
         }
         else
         {
             if ("meta".Equals(localName, StringComparison.OrdinalIgnoreCase))
             {
                 string name = atts.GetValue("name");
                 if (name == null)
                 {
                     name = atts.GetValue("http-equiv");
                 }
                 string val = atts.GetValue("content");
                 if (name != null && val != null)
                 {
                     outerInstance.metaTags[name.ToLowerInvariant()] = val;
                 }
             }
         }
     }
     else if (inBODY > 0)
     {
         if (SUPPRESS_ELEMENTS.Contains(localName))
         {
             suppressed++;
         }
         else if ("img".Equals(localName, StringComparison.OrdinalIgnoreCase))
         {
             // the original javacc-based parser preserved <IMG alt="..."/>
             // attribute as body text in [] parenthesis:
             string alt = atts.GetValue("alt");
             if (alt != null)
             {
                 body.Append('[').Append(alt).Append(']');
             }
         }
     }
     else if ("body".Equals(localName, StringComparison.OrdinalIgnoreCase))
     {
         inBODY++;
     }
     else if ("head".Equals(localName, StringComparison.OrdinalIgnoreCase))
     {
         inHEAD++;
     }
     else if ("frameset".Equals(localName, StringComparison.OrdinalIgnoreCase))
     {
         throw new SAXException("This parser does not support HTML framesets.");
     }
 }
Esempio n. 3
0
 /// <summary>
 ///     Write out an attribute list, escaping values.
 ///     The names will have prefixes added to them.
 /// </summary>
 /// <param name="atts">
 ///     The attribute list to write.
 /// </param>
 /// <exception cref="SAXException">
 ///     If there is an error writing
 ///     the attribute list, this method will throw an
 ///     IOException wrapped in a SAXException.
 /// </exception>
 private void WriteAttributes(IAttributes atts)
 {
     int len = atts.Length;
     for (int i = 0; i < len; i++) {
       char[] ch = atts.GetValue(i).ToCharArray();
       Write(' ');
       WriteName(atts.GetUri(i), atts.GetLocalName(i), atts.GetQName(i), false);
       if (_htmlMode && BoolAttribute(atts.GetLocalName(i), atts.GetQName(i), atts.GetValue(i))) {
     break;
       }
       Write("=\"");
       WriteEsc(ch, 0, ch.Length, true);
       Write('"');
     }
 }
Esempio n. 4
0
        /// <summary>Copy a whole set of attributes.</summary>
        public virtual void SetAttributes(IAttributes atts)
        {
            if (atts == null)
            {
                throw new ArgumentNullException("atts");
            }
            Clear();
            int attLen = atts.Length;

            if (Capacity < attLen)
            {
                Capacity = attLen;
            }
            for (int attIndx = 0; attIndx < attLen; attIndx++)
            {
                InternalSetAttribute(
                    ref this.atts[attIndx],
                    atts.GetUri(attIndx),
                    atts.GetLocalName(attIndx),
                    atts.GetQName(attIndx),
                    atts.GetType(attIndx),
                    atts.GetValue(attIndx),
                    atts.IsSpecified(attIndx));
            }
        }
 private void OutputTextAndTag(string qName, IAttributes attributes, bool close)
 {
     // If we're not already in an element to be transformed, first
     // echo the previous text...
     outWriter.Print(XMLUtils.EscapeXML(textToBeTransformed.ToString()));
     textToBeTransformed = new StringBuilder();
     // ... then echo the new tag to outStream
     outWriter.Print('<');
     if (close)
     {
         outWriter.Print('/');
     }
     outWriter.Print(qName);
     if (attributes != null)
     {
         for (int i = 0; i < attributes.GetLength(); i++)
         {
             outWriter.Print(' ');
             outWriter.Print(attributes.GetQName(i));
             outWriter.Print("=\"");
             outWriter.Print(XMLUtils.EscapeXML(attributes.GetValue(i)));
             outWriter.Print('"');
         }
     }
     outWriter.Print(">\n");
 }
        void IContentHandler.StartElement(string uri, string localName, string qName, IAttributes atts)
        {
            XmlQualifiedName q = new XmlQualifiedName(localName, uri);

            XmlElement elem = m_factory.GetElement(Prefix(qName), q, m_doc);

            for (int i = 0; i < atts.Length; i++)
            {
                XmlAttribute a = m_doc.CreateAttribute(Prefix(atts.GetQName(i)),
                                                       atts.GetLocalName(i),
                                                       atts.GetUri(i));
                a.AppendChild(m_doc.CreateTextNode(atts.GetValue(i)));
                elem.SetAttributeNode(a);
            }

            if ((elem.LocalName != "stream") || (elem.NamespaceURI != URI.STREAM))
            {
                if (m_stanza != null)
                {
                    m_stanza.AppendChild(elem);
                }
                m_stanza = elem;
            }
            else
            {
                FireOnDocumentStart(elem);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Handles IMG tags
        /// </summary>
        /// <returns>The image.</returns>
        /// <param name="text">Text.</param>
        /// <param name="attributes">Attributes.</param>
        /// <param name="img">Image.</param>
        static void startImg(SpannableStringBuilder text, IAttributes attributes, Html.IImageGetter img)
        {
            var      src = attributes.GetValue("src");
            Drawable d   = null;

            if (img != null)
            {
                d = img.GetDrawable(src);
            }

            if (d == null)
            {
                throw new NotImplementedException("Missing Inline image implementation");
                //				d = Resources.System.GetDrawable ();
                //					getDrawable(com.android.internal.R.drawable.unknown_image);

                //				d.SetBounds (0, 0, d.IntrinsicWidth, d.IntrinsicHeight);
            }

            int len = text.Length();

            text.Append("\uFFFC");

            text.SetSpan(new ImageSpan(d, src), len, text.Length(),
                         SpanTypes.ExclusiveExclusive);
        }
        void IContentHandler.StartElement(string uri, string localName, string qName, IAttributes atts)
        {
            XmlQualifiedName q  = new XmlQualifiedName(localName, uri);

            XmlElement elem = m_factory.GetElement(Prefix(qName), q, m_doc);
            for (int i=0; i<atts.Length; i++)
            {
                XmlAttribute a = m_doc.CreateAttribute(Prefix(atts.GetQName(i)),
                    atts.GetLocalName(i),
                    atts.GetUri(i));
                a.AppendChild(m_doc.CreateTextNode(atts.GetValue(i)));
                elem.SetAttributeNode(a);
            }

            if ((elem.LocalName != "stream") || (elem.NamespaceURI != URI.STREAM))
            {
                if (m_stanza != null)
                    m_stanza.AppendChild(elem);
                m_stanza = elem;
            }
            else
            {
                FireOnDocumentStart(elem);
            }
        }
Esempio n. 9
0
            public override void StartElement(string uri, string localName, string qName, IAttributes attributes)
            {
                string tagName = localName.Length != 0 ? localName : qName;

                tagName = tagName.ToLower().Trim();
                if (tagName.Equals("d"))
                {
                    string   pValue = attributes.GetValue("p");
                    string[] values = pValue.Split(",");
                    if (values.Length > 0)
                    {
                        long  time     = (long)(values[0].ToSingle() * 1000);
                        int   type     = values[1].ToInt32();
                        float textSize = values[2].ToSingle();
                        int   color    = (int)((0x00000000ff000000 | values[3].ToInt64()) & 0x00000000ffffffff);
                        item = DanmakuParser.MContext.MDanmakuFactory.CreateDanmaku(type, DanmakuParser.MContext);
                        if (item != null)
                        {
                            item.Time            = time;
                            item.TextSize        = textSize * (DanmakuParser.MDispDensity - 0.6f);
                            item.TextColor       = color;
                            item.TextShadowColor = color <= Color.Black ? Color.White : Color.Black;
                        }
                    }
                }
            }
            public bool Start(BoilerpipeHtmlContentHandler instance, string uri, string localName, string qName, IAttributes attributes)
            {
                string sizeAttr = attributes.GetValue("size");

                if (sizeAttr != null)
                {
                    Match m = FontSizeRegex.Match(sizeAttr);
                    if (m.Success)
                    {
                        string rel = m.Groups[1].Value;
                        int    val = int.Parse(m.Groups[2].Value);
                        int    size;
                        if (rel.Length == 0)
                        {
                            // absolute
                            size = val;
                        }
                        else
                        {
                            // relative
                            int prevSize;
                            if (instance.FontSizeStack.Count == 0)
                            {
                                prevSize = 3;
                            }
                            else
                            {
                                prevSize = 3;
                                foreach (var s in instance.FontSizeStack)
                                {
                                    if (s != null)
                                    {
                                        prevSize = s.Value;
                                        break;
                                    }
                                }
                            }
                            if (rel[0] == '+')
                            {
                                size = prevSize + val;
                            }
                            else
                            {
                                size = prevSize - val;
                            }
                        }
                        instance.FontSizeStack.AddFirst(size);
                    }
                    else
                    {
                        instance.FontSizeStack.AddFirst((int?)null);
                    }
                }
                else
                {
                    instance.FontSizeStack.AddFirst((int?)null);
                }
                return(false);
            }
Esempio n. 11
0
        /// <summary>
        /// Starts an A tag
        /// </summary>
        /// <returns>void</returns>
        /// <param name="text">SpannableStringBuilder</param>
        /// <param name="attributes">IAttributes</param>
        static void startA(SpannableStringBuilder text, IAttributes attributes)
        {
            String href = attributes.GetValue("href");

            int len = text.Length();

            text.SetSpan(new Href(href), len, len, SpanTypes.MarkMark);
        }
Esempio n. 12
0
 public override void StartElement(string uri, string localName, string name, IAttributes attributes)
 {
     _builder = new StringBuilder();
     if (localName == "path")
     {
         List.Add(attributes.GetValue("d"));
     }
 }
Esempio n. 13
0
 public void StartElement(String namespaceURI, String localName, String qName, IAttributes atts) {
   Console.WriteLine("  EVENT: startElement " + makeNSName(namespaceURI, localName, qName));
   int attLen = atts.Length;
   for (int i = 0; i < attLen; i++) {
     char[] ch = atts.GetValue(i).ToCharArray();
     Console.WriteLine("    Attribute " + makeNSName(atts.GetUri(i), atts.GetLocalName(i), atts.GetQName(i)) + '='
                       + escapeData(ch, 0, ch.Length));
   }
 }
Esempio n. 14
0
        public void StartElement(String namespaceURI, String localName, String qName, IAttributes atts)
        {
            Console.WriteLine("  EVENT: startElement " + makeNSName(namespaceURI, localName, qName));
            int attLen = atts.Length;

            for (int i = 0; i < attLen; i++)
            {
                char[] ch = atts.GetValue(i).ToCharArray();
                Console.WriteLine("    Attribute " + makeNSName(atts.GetUri(i), atts.GetLocalName(i), atts.GetQName(i)) + '='
                                  + escapeData(ch, 0, ch.Length));
            }
        }
Esempio n. 15
0
 /// <summary>Add an attribute taken from an existing set of attributes.</summary>
 /// <returns>Index of added attribute.</returns>
 public virtual int AddAttribute(IAttributes atts, int index)
 {
     if (atts == null)
     {
         throw new ArgumentNullException("atts");
     }
     return(AddAttribute(
                atts.GetUri(index),
                atts.GetLocalName(index),
                atts.GetQName(index),
                atts.GetType(index),
                atts.GetValue(index),
                atts.IsSpecified(index)));
 }
Esempio n. 16
0
 public void SetAttributes(IAttributes attributes)
 {
     this.Clear();
     length = attributes.GetLength();
     if (length > 0)
     {
         data = new string[length * 5];
         for (int i = 0; i < length; i++)
         {
             data[i * 5]     = attributes.GetURI(i);
             data[i * 5 + 1] = attributes.GetLocalName(i);
             data[i * 5 + 2] = attributes.GetQName(i);
             data[i * 5 + 3] = attributes.GetType(i);
             data[i * 5 + 4] = attributes.GetValue(i);
         }
     }
 }
Esempio n. 17
0
        private void SetAttributesInternal(IAttributes atts)
        {
            ClearInternal();
            int length = atts.Length;

            if (length > 0)
            {
                _data = new string[length * 5];

                for (int i = 0; i < length; i++)
                {
                    _data[i * 5]     = atts.GetUri(i);
                    _data[i * 5 + 1] = atts.GetLocalName(i);
                    _data[i * 5 + 2] = atts.GetQName(i);
                    _data[i * 5 + 3] = atts.GetType(i);
                    _data[i * 5 + 4] = atts.GetValue(i);
                }
                _length = length;
            }
        }
Esempio n. 18
0
	    /// <summary>
	    /// <para>Receive notification of the beginning of an element.</para><para>The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement event for every startElement event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement event.</para><para>This event allows up to three name components for each element:</para><para><ol><li><para>the Namespace URI; </para></li><li><para>the local name; and </para></li><li><para>the qualified (prefixed) name. </para></li></ol></para><para>Any or all of these may be provided, depending on the values of the <b></b> and the <b></b> properties:</para><para><ul><li><para>the Namespace URI and local name are required when the namespaces property is <b>true</b> (the default), and are optional when the namespaces property is <b>false</b> (if one is specified, both must be); </para></li><li><para>the qualified name is required when the namespace-prefixes property is <b>true</b>, and is optional when the namespace-prefixes property is <b>false</b> (the default). </para></li></ul></para><para>Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes will be omitted. The attribute list will contain attributes used for Namespace declarations (xmlns* attributes) only if the <code></code> property is true (it is false by default, and support for a true value is optional).</para><para>Like characters(), attribute values may have characters that need more than one <code>char</code> value. </para><para><para>endElement </para><simplesectsep></simplesectsep><para>org.xml.sax.Attributes </para><simplesectsep></simplesectsep><para>org.xml.sax.helpers.AttributesImpl </para></para>        
	    /// </summary>
	    public void StartElement(string uri, string localName, string qName, IAttributes atts)
	    {
	        var element = new XElement(XName.Get(localName, uri));
	        var parent = elementStack.Empty() ? null : elementStack.Peek();
	        if (parent == null)
	        {
	            document.Add(element);
	        }
	        else
	        {
	            parent.Add(element);
	        }
	        var attrCount = atts.GetLength();
	        for (var i = 0; i < attrCount; i++)
	        {
	            var name = XName.Get(atts.GetLocalName(i), atts.GetURI(i));
	            var attr = new XAttribute(name, atts.GetValue(i));
	            element.Add(attr);
	        }
	        elementStack.Push(element);
	    }
Esempio n. 19
0
        /// <summary>
        ///     Element构造函数
        /// </summary>
        /// <param name="uri">资源地址</param>
        /// <param name="localName">本地名称(uri有值时tagname为此值)</param>
        /// <param name="qName">q名称(uri为空时tagname为此值)</param>
        /// <param name="attributes">特性集合,可以为null</param>
        /// <param name="locator">定位可以为null</param>
        public Element(string uri, string localName, string qName, IAttributes attributes, ILocator locator)
        {
            this.uri = uri;
            tagName  = string.IsNullOrEmpty(uri) ? qName : localName;

            if (attributes != null)
            {
                for (var i = 0; i < attributes.GetLength(); i++)
                {
                    var attributeUri = attributes.GetUri(i);
                    var name         = string.IsNullOrEmpty(attributeUri) ? attributes.GetQName(i) : attributes.GetLocalName(i);
                    var value        = attributes.GetValue(i);
                    AttributeMap[ComposeMapKey(attributeUri, name)] = new Attribute(name, value, attributeUri);
                }
            }

            if (locator != null)
            {
                line   = locator.GetLineNumber();   //.LineNumber;
                column = locator.GetColumnNumber(); //.ColumnNumber;
            }
        }
Esempio n. 20
0
        /// <summary>
        /// <para>Receive notification of the beginning of an element.</para><para>The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement event for every startElement event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement event.</para><para>This event allows up to three name components for each element:</para><para><ol><li><para>the Namespace URI; </para></li><li><para>the local name; and </para></li><li><para>the qualified (prefixed) name. </para></li></ol></para><para>Any or all of these may be provided, depending on the values of the <b></b> and the <b></b> properties:</para><para><ul><li><para>the Namespace URI and local name are required when the namespaces property is <b>true</b> (the default), and are optional when the namespaces property is <b>false</b> (if one is specified, both must be); </para></li><li><para>the qualified name is required when the namespace-prefixes property is <b>true</b>, and is optional when the namespace-prefixes property is <b>false</b> (the default). </para></li></ul></para><para>Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes will be omitted. The attribute list will contain attributes used for Namespace declarations (xmlns* attributes) only if the <code></code> property is true (it is false by default, and support for a true value is optional).</para><para>Like characters(), attribute values may have characters that need more than one <code>char</code> value. </para><para><para>endElement </para><simplesectsep></simplesectsep><para>org.xml.sax.Attributes </para><simplesectsep></simplesectsep><para>org.xml.sax.helpers.AttributesImpl </para></para>
        /// </summary>
        public void StartElement(string uri, string localName, string qName, IAttributes atts)
        {
            var element = new XElement(XName.Get(localName, uri));
            var parent  = elementStack.Empty() ? null : elementStack.Peek();

            if (parent == null)
            {
                document.Add(element);
            }
            else
            {
                parent.Add(element);
            }
            var attrCount = atts.GetLength();

            for (var i = 0; i < attrCount; i++)
            {
                var name = XName.Get(atts.GetLocalName(i), atts.GetURI(i));
                var attr = new XAttribute(name, atts.GetValue(i));
                element.Add(attr);
            }
            elementStack.Push(element);
        }
Esempio n. 21
0
        public void StartElement(string uri, string localname, string qname, IAttributes atts)
        {
            if (qname.Length == 0)
            {
                qname = localname;
            }
            theWriter.Write('(');
            theWriter.WriteLine(qname);
            int length = atts.Length;

            for (int i = 0; i < length; i++)
            {
                qname = atts.GetQName(i);
                if (qname.Length == 0)
                {
                    qname = atts.GetLocalName(i);
                }
                theWriter.Write('A');
                //			theWriter.Write(atts.getType(i));	// DEBUG
                theWriter.Write(qname);
                theWriter.Write(' ');
                theWriter.WriteLine(atts.GetValue(i));
            }
        }
        public override void StartElement(string uri, string localName, string qName, IAttributes attributes)
        {
            switch (localName.ToLower())
            {
            case "questiongroups":
                QuestionGroups = new Dictionary <string, QuestionGroup>();
                break;

            case "questiongroup":
                questionGroup = new QuestionGroup(attributes.GetValue("name"), attributes.GetValue("text"), attributes.GetValue("background"), int.Parse(attributes.GetValue("thumb")), attributes.GetValue("clue"));
                break;

            case "question":
                question = new Question(attributes.GetValue("id"), attributes.GetValue("text"));
                break;

            case "answer":
                answer = new Answer(bool.Parse(attributes.GetValue("correct")), attributes.GetValue("text"));
                break;
            }
        }
Esempio n. 23
0
        public void StartElement(string uri, string localName, string qName, IAttributes atts)
        {
            seenEvent = true;
              if (inProlog)
              {
            FlushProlog();
            inProlog = false;
              }

              FlushEndPrefixMappings();
              if (startPrefixMappings != null)
              {
            for (int i = 0; i < startPrefixMappings.Count; i++)
            {
              string[] mapping = (string[])startPrefixMappings.GetByIndex(i);
              writer.WriteStartElement("startPrefixMapping");
              writer.WriteStartElement("prefix");
              writer.WriteString(mapping[0]);
              writer.WriteEndElement();
              writer.WriteStartElement("data");
              writer.WriteString(mapping[1]);
              writer.WriteEndElement();
              writer.WriteEndElement();
            }
            startPrefixMappings = null;
              }

              writer.WriteStartElement("startElement");

              if (uri != null)
              {
            writer.WriteStartElement("namespaceURI");
            writer.WriteString(uri);
            writer.WriteEndElement();
              }
              if (localName != null)
              {
            writer.WriteStartElement("localName");
            writer.WriteString(localName);
            writer.WriteEndElement();
              }
              if (qName != null)
              {
            writer.WriteStartElement("qualifiedName");
            writer.WriteString(qName);
            writer.WriteEndElement();
              }

              writer.WriteStartElement("attributes");
              SortedList sortedAtts = new SortedList();
              for (int i = 0; i < atts.Length; i++)
              {
            string ln = atts.GetLocalName(i);
            string qn = atts.GetQName(i);
            string ns = atts.GetUri(i);
            string key = "";
            if (ln != null) key += ln;
            key += '\u0000';
            if (qn != null) key += qn;
            key += '\u0000';
            if (ns != null) key += ns;
            sortedAtts.Add(key, i);
              }

              for (int i = 0; i < sortedAtts.Count; i++)
              {
            int index = (int)sortedAtts.GetByIndex(i);
            string ln = atts.GetLocalName(i);
            string qn = atts.GetQName(i);
            string ns = atts.GetUri(i);
            string val = atts.GetValue(i);
            string typ = atts.GetType(i);
            writer.WriteStartElement("attribute");

            if (ns != null)
            {
              writer.WriteStartElement("namespaceURI");
              writer.WriteString(ns);
              writer.WriteEndElement();
            }
            if (ln != null)
            {
              writer.WriteStartElement("localName");
              writer.WriteString(ln);
              writer.WriteEndElement();
            }
            if (qn != null)
            {
              writer.WriteStartElement("qualifiedName");
              writer.WriteString(qn);
              writer.WriteEndElement();
            }
            writer.WriteStartElement("value");
            writer.WriteString(Escape(val));
            writer.WriteEndElement();
            writer.WriteStartElement("type");
            writer.WriteString(Escape(typ));
            writer.WriteEndElement();

            writer.WriteEndElement();
              }
              writer.WriteEndElement();
              writer.WriteEndElement();
        }
Esempio n. 24
0
 public virtual void StartElement(
     string uri, string localName, string qName, IAttributes atts)
 {
     TreeNodeCollection nodes = CheckTextNode();
     currentNode = new TreeNode(qName, 0, 0);
     for (int indx = 0; indx < atts.Length; indx ++) {
       string attStr = atts.GetQName(indx) + "=\"" + atts.GetValue(indx) + "\"";
       currentNode.Nodes.Add(new TreeNode(attStr, 1, 1));
     }
     nodes.Add(currentNode);
 }
Esempio n. 25
0
        public void StartElement(string uri, string localName, string qName, IAttributes atts)
        {
            //System.Diagnostics.Debug.WriteLine("StartElement");
            if (_nsXmlInterface != null)
            {
                CharactersWorkaround();

                NSMutableDictionary attributeDict = (NSMutableDictionary)NSMutableDictionary.Alloc().Init();
                for (int indx = 0; indx < atts.Length; indx++)
                {
                    NSString key = (NSString)atts.GetQName(indx);
                    NSString val = (NSString)atts.GetValue(indx);
                    attributeDict.Add(key, val);
                }

                //SEL sel;
                //if (Objc.RespondsToSelector(_delegate, "ParserDidStartElement", ref sel))
                //{
                //    sel.MsgSend(this, localName, uri, qName, attributeDict);
                //}
                _nsXmlInterface.ParserDidStartElement(this, localName, uri, qName, attributeDict);
            }
        }
Esempio n. 26
0
 public void StartElement(string uri, string localName, string qName, IAttributes atts)
 {
     if (localName.Equals("TEST")) {
     inTest = true;
     currId = atts.GetValue("ID");
     currSections = atts.GetValue("SECTIONS");
     currType = atts.GetValue("TYPE");
     currUri = atts.GetValue("URI");
     currEntities = GetAttValue(atts, "ENTITIES");
     currRecommendation = GetAttValue(atts, "RECOMMENDATION");
     currVersion = GetAttValue(atts, "VERSION");
     currNamespaces = GetAttValue(atts, "NAMESPACE");
     currContent.Length = 0;
     return;
       }
       if (localName.Equals("TESTCASES")) {
     currProfile = atts.GetValue("PROFILE");
     // string baseUriStr = GetAttValue(atts, "xml:base");
     if (console)
       Console.WriteLine("\n=======================================================================\n" +
     currProfile +
     "\n=======================================================================\n");
     return;
       }
       if (localName.Equals("TESTSUITE")) {
     if (console)
       Console.WriteLine("\nTest suite for " + atts.GetValue("PROFILE"));
     return;
       }
       if (inTest)
     currContent.Append("<" + qName + ">");
 }
Esempio n. 27
0
 private static string GetAttValue(IAttributes atts, string name)
 {
     string value;
       int indx = atts.GetIndex(name);
       if (indx >= 0)
     value = atts.GetValue(indx);
       else
     value = null;
       return value;
 }
Esempio n. 28
0
 /// <summary>
 ///     Write out an attribute list, escaping values.
 ///     The names will have prefixes added to them.
 /// </summary>
 /// <param name="atts">
 ///     The attribute list to write.
 /// </param>
 /// <exception cref="SAXException">
 ///     If there is an error writing
 ///     the attribute list, this method will throw an
 ///     IOException wrapped in a SAXException.
 /// </exception>
 private void WriteAttributes(IAttributes atts) {
   int len = atts.Length;
   for (int i = 0; i < len; i++) {
     char[] ch = atts.GetValue(i).ToCharArray();
     Write(' ');
     WriteName(atts.GetUri(i), atts.GetLocalName(i), atts.GetQName(i), false);
     if (_htmlMode && BoolAttribute(atts.GetLocalName(i), atts.GetQName(i), atts.GetValue(i))) {
       break;
     }
     Write("=\"");
     WriteEsc(ch, 0, ch.Length, true);
     Write('"');
   }
 }
Esempio n. 29
0
     public override void StartElement(string uri, string localName, string arg2,
 IAttributes arg3)
     {
         string prefix=getPrefix(arg2);
           Element element=new Element();
           element.setLocalName(localName);
           if(prefix.Length>0){
         element.setPrefix(prefix);
           }
           if(uri!=null && uri.Length>0){
         element.setNamespace(uri);
           }
           getCurrentNode().appendChild(element);
           for(int i=0;i<arg3.Length;i++){
         string _namespace=arg3.GetUri(i);
         Attr attr=new Attr();
         attr.setName(arg3.GetQName(i)); // Sets prefix and local name
         attr.setNamespace(_namespace);
         attr.setValue(arg3.GetValue(i));
         element.addAttribute(attr);
         if("xml:base".Equals(arg3.GetQName(i))){
           xmlBaseElements.Add(element);
         }
           }
           if("http://www.w3.org/1999/xhtml".Equals(uri) &&
           "base".Equals(localName)){
         string href=element.getAttributeNS("", "href");
         if(href!=null) {
           baseurl=href;
         }
           }
           elements.Add(element);
     }
Esempio n. 30
0
    private void SetAttributesInternal(IAttributes atts) {
      ClearInternal();
      int length = atts.Length;
      if (length > 0) {
        _data = new string[length * 5];

        for (int i = 0; i < length; i++) {
          _data[i * 5] = atts.GetUri(i);
          _data[i * 5 + 1] = atts.GetLocalName(i);
          _data[i * 5 + 2] = atts.GetQName(i);
          _data[i * 5 + 3] = atts.GetType(i);
          _data[i * 5 + 4] = atts.GetValue(i);
        }
        _length = length;
      }
    }
Esempio n. 31
0
        // throws SAXException
        public void startElement(string uri, string localName, string qName, IAttributes atts)
        {
            base.StartElement (uri, localName, qName, atts);

            if (localName.CompareTo ("metric") == 0) {
                inMetric = true;
                 if (metrics == null)
                     metrics = new List<Metric> ();
                values = new List<Value> ();
            } else if (localName.CompareTo ("id") == 0 && inMetric)
                inId = true;
            else if (localName.CompareTo ("identifier") == 0 && inMetric)
                inIdentifier = true;
            else if (localName.CompareTo ("host") == 0 && inMetric)
                inHost = true;
            else if (localName.CompareTo ("plugin") == 0 && inMetric)
                inPlugin = true;
            else if (localName.CompareTo ("plugin_instance") == 0 && inMetric)
                inPluginInstance = true;
            else if (localName.CompareTo ("type") == 0 && inMetric)
                inType = true;
            else if (localName.CompareTo ("type_instance") == 0 && inMetric)
                inTypeInstance = true;
            else if (localName.CompareTo ("limits") == 0 && inMetric) {
                inLimits = true;
                limits = new List<Limit> ();
            } else if (localName.CompareTo ("limit") == 0 && inLimits)
                inLimit = true;
            else if (localName.CompareTo ("metric_column") == 0 && inLimit)
                inMetricColumn = true;
            else if (localName.CompareTo ("max") == 0 && inLimit)
                inMax = true;
            else if (localName.CompareTo ("min") == 0 && inLimit)
                inMin = true;
            else if (localName.CompareTo ("value") == 0 && inMetric) {
                if (!inValueRoot) {
                    inValueRoot = true;
                    int result;
                    int.TryParse (atts.GetValue ("interval"), out result);
                    interval = result;
                    column = atts.GetValue ("column");
                    int.TryParse (atts.GetValue ("start"), out result);
                    start = result;
                    floatValues = new List<float> ();
                } else // inner <value>
                    inValue = true;
            }
        }