AttrError() public static method

public static AttrError ( Lexer lexer, Node node, string attr, short code ) : void
lexer Lexer
node Node
attr string
code short
return void
Exemplo n.º 1
0
        public virtual void Check(Lexer lexer, Node node, AttVal attval)
        {
            string val = attval.Val;

            if (val == null)
            {
                Report.AttrError(lexer, node, attval.Attribute, Report.MISSING_ATTR_VALUE);
            }
            else if (String.CompareOrdinal(val, "top") == 0 || String.CompareOrdinal(val, "middle") == 0 ||
                     String.CompareOrdinal(val, "bottom") == 0 || String.CompareOrdinal(val, "baseline") == 0)
            {
                /* all is fine */
            }
            else if (String.CompareOrdinal(val, "left") == 0 || String.CompareOrdinal(val, "right") == 0)
            {
                if (!(node.Tag != null && ((node.Tag.Model & ContentModel.IMG) != 0)))
                {
                    Report.AttrError(lexer, node, val, Report.BAD_ATTRIBUTE_VALUE);
                }
            }
            else if (String.CompareOrdinal(val, "texttop") == 0 || String.CompareOrdinal(val, "absmiddle") == 0 ||
                     String.CompareOrdinal(val, "absbottom") == 0 || String.CompareOrdinal(val, "textbottom") == 0)
            {
                lexer.Versions &= HtmlVersion.Proprietary;
                Report.AttrError(lexer, node, val, Report.PROPRIETARY_ATTR_VALUE);
            }
            else
            {
                Report.AttrError(lexer, node, val, Report.BAD_ATTRIBUTE_VALUE);
            }
        }
        public virtual void Check(Lexer lexer, Node node)
        {
            AttVal attval;
            string val = null;

            node.CheckUniqueAttributes(lexer);

            for (attval = node.Attributes; attval != null; attval = attval.Next)
            {
                if (String.CompareOrdinal(attval.Attribute, "align") == 0)
                {
                    val = attval.Val;
                    break;
                }
            }

            if (val != null)
            {
                if (String.CompareOrdinal(val, "left") == 0 || String.CompareOrdinal(val, "right") == 0)
                {
                    lexer.Versions &= HtmlVersion.Html40Loose | HtmlVersion.Frames;
                }
                else if (String.CompareOrdinal(val, "top") == 0 || String.CompareOrdinal(val, "bottom") == 0)
                {
                    lexer.Versions &= HtmlVersion.From32;
                }
                else
                {
                    Report.AttrError(lexer, node, val, Report.BAD_ATTRIBUTE_VALUE);
                }
            }
        }
Exemplo n.º 3
0
        public virtual void Check(Lexer lexer, Node node)
        {
            node.CheckUniqueAttributes(lexer);

            AttVal lang = node.GetAttrByName("language");
            AttVal type = node.GetAttrByName("type");

            if (type == null)
            {
                Report.AttrError(lexer, node, "type", Report.MISSING_ATTRIBUTE);

                /* check for javascript */
                if (lang != null)
                {
                    string str = lang.Val;
                    if (str.Length > 10)
                    {
                        str = str.Substring(0, 10);
                    }

                    if ((String.CompareOrdinal(str, "javascript") == 0) || (String.CompareOrdinal(str, "jscript") == 0))
                    {
                        node.AddAttribute("type", "text/javascript");
                    }
                }
                else
                {
                    node.AddAttribute("type", "text/javascript");
                }
            }
        }
Exemplo n.º 4
0
        /*
         *      the same attribute name can't be used
         *      more than once in each element
         */

        public virtual void CheckUniqueAttribute(Lexer lexer, Node node)
        {
            AttVal attr;
            int    count = 0;

            for (attr = Next; attr != null; attr = attr.Next)
            {
                if (Attribute != null && attr.Attribute != null && attr.Asp == null && attr.Php == null &&
                    String.CompareOrdinal(Attribute, attr.Attribute) == 0)
                {
                    ++count;
                }
            }

            if (count > 0)
            {
                Report.AttrError(lexer, node, Attribute, Report.REPEATED_ATTRIBUTE);
            }
        }
Exemplo n.º 5
0
        /* ignore unknown attributes for proprietary elements */

        public virtual Attribute CheckAttribute(Lexer lexer, Node node)
        {
            TagCollection tt = lexer.Options.TagTable;

            if (Asp == null && Php == null)
            {
                CheckUniqueAttribute(lexer, node);
            }

            Attribute attribute = Dict;

            if (attribute != null)
            {
                /* title is vers 2.0 for A and LINK otherwise vers 4.0 */
                if (attribute == AttributeTable.AttrTitle && (node.Tag == tt.TagA || node.Tag == tt.TagLink))
                {
                    lexer.Versions &= HtmlVersion.All;
                }
                else if ((attribute.Versions & HtmlVersion.Xml) != 0)
                {
                    if (!(lexer.Options.XmlTags || lexer.Options.XmlOut))
                    {
                        Report.AttrError(lexer, node, Attribute, Report.XML_ATTRIBUTE_VALUE);
                    }
                }
                else
                {
                    lexer.Versions &= attribute.Versions;
                }

                if (attribute.AttrCheck != null)
                {
                    attribute.AttrCheck.Check(lexer, node, this);
                }
            }
            else if (!lexer.Options.XmlTags && node.Tag != null && _asp == null &&
                     !(node.Tag != null && ((node.Tag.Versions & HtmlVersion.Proprietary) != HtmlVersion.Unknown)))
            {
                Report.AttrError(lexer, node, Attribute, Report.UNKNOWN_ATTRIBUTE);
            }

            return(attribute);
        }
Exemplo n.º 6
0
        public virtual void Check(Lexer lexer, Node node, AttVal attval)
        {
            /* IMG, OBJECT, APPLET and EMBED use align for vertical position */
            if (node.Tag != null && ((node.Tag.Model & ContentModel.IMG) != 0))
            {
                AttrCheckImpl.CheckValign.Check(lexer, node, attval);
                return;
            }

            string val = attval.Val;

            if (val == null)
            {
                Report.AttrError(lexer, node, attval.Attribute, Report.MISSING_ATTR_VALUE);
            }
            else if (
                !(String.CompareOrdinal(val, "left") == 0 || String.CompareOrdinal(val, "center") == 0 ||
                  String.CompareOrdinal(val, "right") == 0 || String.CompareOrdinal(val, "justify") == 0))
            {
                Report.AttrError(lexer, node, attval.Val, Report.BAD_ATTRIBUTE_VALUE);
            }
        }