Exemple #1
0
        public void AbsorbLeadingBlanksBlankTag()
        {
            string testData = "";
            string result   = TagScanner.AbsorbLeadingBlanks(testData);

            Assert.AreEqual("", result);
        }
Exemple #2
0
        /// <summary> Template Method, used to decide if this scanner can handle the Link tag type. If
        /// the evaluation returns true, the calling side makes a call to scan().
        /// </summary>
        /// <param name="s">The complete text contents of the Tag.
        /// </param>
        /// <param name="previousOpenScanner">Indicates any previous scanner which hasnt completed, before the current
        /// scan has begun, and hence allows us to write scanners that can work with dirty html
        ///
        /// </param>
        public override bool Evaluate(string s, TagScanner previousOpenScanner)
        {
            char ch;
            bool ret;

            // eat up leading blanks
            s = AbsorbLeadingBlanks(s);
            if (5 > s.Length)
            {
                ret = false;
            }
            else
            {
                ch = s[0];
                if ((ch == 'a' || ch == 'A') && System.Char.IsWhiteSpace(s[1]))
                {
                    ret = -1 != s.ToUpper().IndexOf("HREF");
                }
                else
                {
                    ret = false;
                }
            }

            return(ret);
        }
Exemple #3
0
        public void AbsorbLeadingBlanks()
        {
            string test   = "   This is a test";
            string result = TagScanner.AbsorbLeadingBlanks(test);

            Assert.AreEqual("This is a test", result, "Absorb test");
        }
Exemple #4
0
 public void ExtractXMLDataSingle()
 {
     CreateParser("<MESSAGE>Test</MESSAGE>");
     foreach (Node node in parser)
     {
         string result = TagScanner.ExtractXMLData(node, "MESSAGE", parser.Reader);
         Assert.AreEqual("Test", result, "Result");
     }
 }
Exemple #5
0
        public void IsXMLTag()
        {
            CreateParser("<OPTION value=\"#\">Select a destination</OPTION>");
            NodeIterator iterator = parser.GetEnumerator();

            iterator.MoveNext();
            Node node = (Node)iterator.Current;

            Assert.IsTrue(TagScanner.IsXMLTagFound(node, "OPTION"), "OPTION tag could not be identified");
        }
Exemple #6
0
        public void ExtractXMLData()
        {
            CreateParser("<MESSAGE>\n" + "Abhi\n" + "Sri\n" + "</MESSAGE>");
            Parser.LineSeparator = "\r\n";

            foreach (Node node in parser)
            {
                string result = TagScanner.ExtractXMLData(node, "MESSAGE", parser.Reader);
                Assert.AreEqual("Abhi\r\nSri\r\n", result, "Result");
            }
        }
 /// <summary> Scan the tag and extract the information related to the <IMG> tag. The url of the
 /// initiating scan has to be provided in case relative links are found. The initial
 /// url is then prepended to it to give an absolute link.
 /// The NodeReader is provided in order to do a lookahead operation. We assume that
 /// the identification has already been performed using the Evaluate() method.
 /// </summary>
 /// <param name="tag">HTML Tag to be scanned for identification
 /// </param>
 /// <param name="url">The initiating url of the scan (Where the html page lies)
 /// </param>
 /// <param name="reader">The reader object responsible for reading the html page
 /// </param>
 /// <param name="currentLine">The current line (automatically provided by Tag)
 ///
 /// </param>
 public override bool Evaluate(string s, TagScanner previousOpenScanner)
 {
     if (previousOpenScanner is LinkScanner)
     {
         System.Text.StringBuilder msg = new System.Text.StringBuilder();
         msg.Append("<");
         msg.Append(s);
         msg.Append(">");
         msg.Append(PREVIOUS_DIRTY_LINK_MESSAGE);
         feedback.Warning(msg.ToString());
         // This is dirty HTML. Assume the current tag is
         // not a new link tag - but an end tag. This is actually a really wild bug -
         // Internet Explorer actually parses such tags.
         // So - we shall then proceed to fool the scanner into sending an endtag of type </A>
         // For this - set the dirty flag to true and return
     }
     return(base.Evaluate(s, previousOpenScanner));
 }
 /// <summary> This method is used to decide if this scanner can handle this tag type. If the
 /// evaluation returns true, the calling side makes a call to Scan().
 /// <strong>This method has to be implemented meaningfully only if a first-word match with
 /// the scanner id does not imply a match (or extra processing needs to be done).
 /// Default returns true</strong>
 /// </summary>
 /// <param name="s">The complete text contents of the Tag.
 /// </param>
 /// <param name="previousOpenScanner">Indicates any previous scanner which hasn't completed, before the current
 /// scan has begun, and hence allows us to write scanners that can work with dirty html
 ///
 /// </param>
 public virtual bool Evaluate(string s, TagScanner previousOpenScanner)
 {
     return(true);
 }
 public override bool Evaluate(string tagNameBeingChecked, TagScanner previousOpenScanner)
 {
     AbsorbLeadingBlanks(tagNameBeingChecked);
     return(tagNameBeingChecked.ToUpper().StartsWith(MATCH_NAME[0]) &&
            ((null == previousOpenScanner) || !previousOpenScanner.ID[0].Equals("TITLE")));
 }
Exemple #10
0
 public override bool Evaluate(string s, TagScanner previousOpenScanner)
 {
     return(false);
 }