Exemplo n.º 1
0
        public virtual void RemoveAttribute(string name)
        {
            if (Adaptee == null)
            {
                return;
            }

            AttVal att = Adaptee.Attributes;
            AttVal pre = null;

            while (att != null)
            {
                if (att.Attribute.Equals(name))
                {
                    break;
                }
                pre = att;
                att = att.Next;
            }
            if (att != null)
            {
                if (pre == null)
                {
                    Adaptee.Attributes = att.Next;
                }
                else
                {
                    pre.Next = att.Next;
                }
            }
        }
Exemplo n.º 2
0
        public virtual string GetAttribute(string name)
        {
            if (Adaptee == null)
            {
                return(null);
            }

            AttVal att = Adaptee.Attributes;

            while (att != null)
            {
                if (att.Attribute.Equals(name))
                {
                    break;
                }
                att = att.Next;
            }
            if (att != null)
            {
                return(att.Val);
            }
            else
            {
                return(String.Empty);
            }
        }
Exemplo n.º 3
0
        /* remove attribute from node then free it */
        public virtual void RemoveAttribute(AttVal attr)
        {
            AttVal av;
            AttVal prev = null;
            AttVal next;

            for (av = _attributes; av != null; av = next)
            {
                next = av.Next;

                if (av == attr)
                {
                    if (prev != null)
                    {
                        prev.Next = next;
                    }
                    else
                    {
                        _attributes = next;
                    }
                }
                else
                {
                    prev = av;
                }
            }
        }
Exemplo n.º 4
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.Compare(str, "javascript") == 0) || (String.Compare(str, "jscript") == 0))
                    {
                        node.AddAttribute("type", "text/javascript");
                    }
                }
                else
                {
                    node.AddAttribute("type", "text/javascript");
                }
            }
        }
Exemplo n.º 5
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.Compare(val, "top") == 0 || String.Compare(val, "middle") == 0 || String.Compare(val, "bottom") == 0 || String.Compare(val, "baseline") == 0)
            {
                /* all is fine */
            }
            else if (String.Compare(val, "left") == 0 || String.Compare(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.Compare(val, "texttop") == 0 || String.Compare(val, "absmiddle") == 0 || String.Compare(val, "absbottom") == 0 || String.Compare(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);
            }
        }
Exemplo n.º 6
0
        public object Clone()
        {
            AttVal av = new AttVal();

            if (Next != null)
            {
                av.Next = (AttVal)Next.Clone();
            }
            if (Attribute != null)
            {
                av.Attribute = Attribute;
            }
            if (Val != null)
            {
                av.Val = Val;
            }
            av.Delim = Delim;
            if (Asp != null)
            {
                av.Asp = (Node)Asp.Clone();
            }
            if (Php != null)
            {
                av.Php = (Node)Php.Clone();
            }
            av.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(this);
            return(av);
        }
Exemplo n.º 7
0
        private Dict _tag; /* tag's dictionary definition */

        #endregion Fields

        #region Constructors

        /*
        Mosaic handles inlines via a separate stack from other elements
        We duplicate this to recover from inline markup errors such as:

        <i>italic text
        <p>more italic text</b> normal text

        which for compatibility with Mosaic is mapped to:

        <i>italic text</i>
        <p><i>more italic text</i> normal text

        Note that any inline end tag pop's the effect of the current
        inline start tag, so that </b> pop's <i> in the above example.
        */
        public InlineStack()
        {
            _next = null;
            _tag = null;
            _element = null;
            _attributes = null;
        }
Exemplo n.º 8
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.Compare(val, "top") == 0 || String.Compare(val, "middle") == 0 || String.Compare(val, "bottom") == 0 || String.Compare(val, "baseline") == 0)
            {
                /* all is fine */
            }
            else if (String.Compare(val, "left") == 0 || String.Compare(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.Compare(val, "texttop") == 0 || String.Compare(val, "absmiddle") == 0 || String.Compare(val, "absbottom") == 0 || String.Compare(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);
            }
        }
Exemplo n.º 9
0
 public AttVal()
 {
     _next = null;
     _dict = null;
     _asp = null;
     _php = null;
     _delim = 0;
     _attribute = null;
     _val = null;
 }
Exemplo n.º 10
0
 public AttVal(AttVal next, Attribute dict, Node asp, Node php, int delim, string attribute, string val)
 {
     _next      = next;
     _dict      = dict;
     _asp       = asp;
     _php       = php;
     _delim     = delim;
     _attribute = attribute;
     _val       = val;
 }
Exemplo n.º 11
0
 public AttVal(AttVal next, Attribute dict, int delim, string attribute, string val)
 {
     _next      = next;
     _dict      = dict;
     _asp       = null;
     _php       = null;
     _delim     = delim;
     _attribute = attribute;
     _val       = val;
 }
Exemplo n.º 12
0
 public AttVal(AttVal next, Attribute dict, Node asp, Node php, int delim, string attribute, string val)
 {
     _next = next;
     _dict = dict;
     _asp = asp;
     _php = php;
     _delim = delim;
     _attribute = attribute;
     _val = val;
 }
Exemplo n.º 13
0
 public AttVal(AttVal next, Attribute dict, int delim, string attribute, string val)
 {
     _next = next;
     _dict = dict;
     _asp = null;
     _php = null;
     _delim = delim;
     _attribute = attribute;
     _val = val;
 }
Exemplo n.º 14
0
 public virtual void Check(Lexer lexer, Node node, AttVal attval)
 {
     if (attval.Val == null)
     {
         Report.AttrError(lexer, node, attval.Attribute, Report.MISSING_ATTR_VALUE);
     }
     else if (lexer.Options.FixBackslash)
     {
         attval.Val = attval.Val.Replace('\\', '/');
     }
 }
Exemplo n.º 15
0
 public virtual void Check(Lexer lexer, Node node, AttVal attval)
 {
     if (attval.Val == null)
     {
         Report.AttrError(lexer, node, attval.Attribute, Report.MISSING_ATTR_VALUE);
     }
     else if (lexer.Options.FixBackslash)
     {
         attval.Val = attval.Val.Replace('\\', '/');
     }
 }
Exemplo n.º 16
0
        /* public method for finding attribute definition by name */
        public virtual Attribute FindAttribute(AttVal attval)
        {
            Attribute np;

            if (attval.Attribute != null)
            {
                np = Lookup(attval.Attribute);
                return(np);
            }

            return(null);
        }
        public virtual void Check(Lexer lexer, Node node)
        {
            AttVal type = node.GetAttrByName("type");

            node.CheckUniqueAttributes(lexer);

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

                node.AddAttribute("type", "text/css");
            }
        }
Exemplo n.º 18
0
        public virtual IAttr CreateAttribute(string name)
        {
            AttVal av = new AttVal(null, null, (int)'"', name, null);

            if (av != null)
            {
                av.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(av);
                return((IAttr)av.Adapter);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 19
0
        public virtual IAttr SetAttributeNode(IAttr newAttr)
        {
            if (newAttr == null)
            {
                return(null);
            }

            if (!(newAttr is DomAttrImpl))
            {
                throw new DomException(DomException.WrongDocument, "newAttr not instanceof DomAttrImpl");
            }

            DomAttrImpl newatt = (DomAttrImpl)newAttr;
            string      name   = newatt.AttValAdaptee.Attribute;
            IAttr       result = null;

            AttVal att = Adaptee.Attributes;

            while (att != null)
            {
                if (att.Attribute.Equals(name))
                {
                    break;
                }
                att = att.Next;
            }
            if (att != null)
            {
                result      = att.Adapter;
                att.Adapter = newAttr;
            }
            else
            {
                if (Adaptee.Attributes == null)
                {
                    Adaptee.Attributes = newatt.AttValAdaptee;
                }
                else
                {
                    newatt.AttValAdaptee.Next = Adaptee.Attributes;
                    Adaptee.Attributes        = newatt.AttValAdaptee;
                }
            }
            return(result);
        }
        public virtual void Check(Lexer lexer, Node node)
        {
            AttVal rel = node.GetAttrByName("rel");

            node.CheckUniqueAttributes(lexer);

            if (rel != null && rel.Val != null && rel.Val.Equals("stylesheet"))
            {
                AttVal type = node.GetAttrByName("type");

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

                    node.AddAttribute("type", "text/css");
                }
            }
        }
Exemplo n.º 21
0
        public static void AddClass(Node node, string classname)
        {
            AttVal classattr = node.GetAttrByName("class");

            /*
             * if there already is a class attribute
             * then append class name after a space
             */
            if (classattr != null)
            {
                classattr.Val = classattr.Val + " " + classname;
            }
            /* create new class attribute */
            else
            {
                node.AddAttribute("class", classname);
            }
        }
Exemplo n.º 22
0
        public virtual void Check(Lexer lexer, Node node, AttVal attval)
        {
            string val;

            /* IMG, OBJECT, APPLET and EMBED use align for vertical position */
            if (node.Tag != null && ((node.Tag.Model & ContentModel.Img) != 0))
            {
                TidyNet.AttrCheckImpl.CheckValign.Check(lexer, node, attval);
                return;
            }

            val = attval.Val;

            if (val == null)
            {
                Report.AttrError(lexer, node, attval.Attribute, Report.MISSING_ATTR_VALUE);
            }
            else if (!(String.Compare(val, "left") == 0 || String.Compare(val, "center") == 0 || String.Compare(val, "right") == 0 || String.Compare(val, "justify") == 0))
            {
                Report.AttrError(lexer, node, attval.Val, Report.BAD_ATTRIBUTE_VALUE);
            }
        }
Exemplo n.º 23
0
        public virtual void Check(Lexer lexer, Node node, AttVal attval)
        {
            string val;

            /* IMG, OBJECT, APPLET and EMBED use align for vertical position */
            if (node.Tag != null && ((node.Tag.Model & ContentModel.Img) != 0))
            {
                TidyNet.AttrCheckImpl.CheckValign.Check(lexer, node, attval);
                return;
            }

            val = attval.Val;

            if (val == null)
            {
                Report.AttrError(lexer, node, attval.Attribute, Report.MISSING_ATTR_VALUE);
            }
            else if (!(String.Compare(val, "left") == 0 || String.Compare(val, "center") == 0 || String.Compare(val, "right") == 0 || String.Compare(val, "justify") == 0))
            {
                Report.AttrError(lexer, node, attval.Val, Report.BAD_ATTRIBUTE_VALUE);
            }
        }
Exemplo n.º 24
0
        public virtual INode GetNamedItem(string name)
        {
            AttVal att = _first;

            while (att != null)
            {
                if (att.Attribute.Equals(name))
                {
                    break;
                }
                att = att.Next;
            }

            if (att != null)
            {
                return(att.Adapter);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 25
0
        public virtual IAttr RemoveAttributeNode(IAttr oldAttr)
        {
            if (oldAttr == null)
            {
                return(null);
            }

            IAttr  result = null;
            AttVal att    = Adaptee.Attributes;
            AttVal pre    = null;

            while (att != null)
            {
                if (att.Adapter == oldAttr)
                {
                    break;
                }
                pre = att;
                att = att.Next;
            }
            if (att != null)
            {
                if (pre == null)
                {
                    Adaptee.Attributes = att.Next;
                }
                else
                {
                    pre.Next = att.Next;
                }
                result = oldAttr;
            }
            else
            {
                throw new DomException(DomException.NotFound, "oldAttr not found");
            }
            return(result);
        }
Exemplo n.º 26
0
        public virtual void AddAttribute(string name, string val)
        {
            AttVal av = new AttVal(null, null, null, null, '"', name, val);

            av.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(av);

            if (_attributes == null)
            {
                _attributes = av;
                /* append to end of attributes */
            }
            else
            {
                AttVal here = _attributes;

                while (here.Next != null)
                {
                    here = here.Next;
                }

                here.Next = av;
            }
        }
Exemplo n.º 27
0
        public virtual INode Item(int index)
        {
            int    i   = 0;
            AttVal att = _first;

            while (att != null)
            {
                if (i >= index)
                {
                    break;
                }
                i++;
                att = att.Next;
            }

            if (att != null)
            {
                return(att.Adapter);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 28
0
        public virtual void SetAttribute(string name, string val)
        {
            if (Adaptee == null)
            {
                return;
            }

            AttVal att = Adaptee.Attributes;

            while (att != null)
            {
                if (att.Attribute.Equals(name))
                {
                    break;
                }
                att = att.Next;
            }
            if (att != null)
            {
                att.Val = val;
            }
            else
            {
                att      = new AttVal(null, null, (int)'"', name, val);
                att.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(att);
                if (Adaptee.Attributes == null)
                {
                    Adaptee.Attributes = att;
                }
                else
                {
                    att.Next           = Adaptee.Attributes;
                    Adaptee.Attributes = att;
                }
            }
        }
Exemplo n.º 29
0
 public virtual void Check(Lexer lexer, Node node, AttVal attval)
 {
 }
Exemplo n.º 30
0
 public object Clone()
 {
     AttVal av = new AttVal();
     if (Next != null)
     {
         av.Next = (AttVal)Next.Clone();
     }
     if (Attribute != null)
     {
         av.Attribute = Attribute;
     }
     if (Val != null)
     {
         av.Val = Val;
     }
     av.Delim = Delim;
     if (Asp != null)
     {
         av.Asp = (Node) Asp.Clone();
     }
     if (Php != null)
     {
         av.Php = (Node) Php.Clone();
     }
     av.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(this);
     return av;
 }
Exemplo n.º 31
0
        /*
        add style properties to node corresponding to
        the font face, size and color attributes
        */
        private void AddFontStyles(Node node, AttVal av)
        {
            while (av != null)
            {
                if (av.Attribute.Equals("face"))
                {
                    AddFontFace(node, av.Val);
                }
                else if (av.Attribute.Equals("size"))
                {
                    AddFontSize(node, av.Val);
                }
                else if (av.Attribute.Equals("color"))
                {
                    AddFontColor(node, av.Val);
                }

                av = av.Next;
            }
        }
Exemplo n.º 32
0
        /*
        Add style property to element, creating style
        attribute as needed and adding ; delimiter
        */
        private void AddStyleProperty(Node node, string property)
        {
            AttVal av;

            for (av = node.Attributes; av != null; av = av.Next)
            {
                if (av.Attribute.Equals("style"))
                {
                    break;
                }
            }

            /* if style attribute already exists then insert property */

            if (av != null)
            {
                string s;

                s = AddProperty(av.Val, property);
                av.Val = s;
            }
            else
            {
                /* else create new style attribute */
                av = new AttVal(node.Attributes, null, '"', "style", property);
                av.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(av);
                node.Attributes = av;
            }
        }
Exemplo n.º 33
0
        public virtual void SetAttribute(string name, string val)
        {
            if (Adaptee == null)
            {
                return;
            }

            AttVal att = Adaptee.Attributes;
            while (att != null)
            {
                if (att.Attribute.Equals(name))
                {
                    break;
                }
                att = att.Next;
            }
            if (att != null)
            {
                att.Val = val;
            }
            else
            {
                att = new AttVal(null, null, (int) '"', name, val);
                att.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(att);
                if (Adaptee.Attributes == null)
                {
                    Adaptee.Attributes = att;
                }
                else
                {
                    att.Next = Adaptee.Attributes;
                    Adaptee.Attributes = att;
                }
            }
        }
Exemplo n.º 34
0
        /* remove attribute from node then free it */
        public virtual void RemoveAttribute(AttVal attr)
        {
            AttVal av;
            AttVal prev = null;
            AttVal next;

            for (av = _attributes; av != null; av = next)
            {
                next = av.Next;

                if (av == attr)
                {
                    if (prev != null)
                    {
                        prev.Next = next;
                    }
                    else
                    {
                        _attributes = next;
                    }
                }
                else
                {
                    prev = av;
                }
            }
        }
Exemplo n.º 35
0
 protected internal DomAttrMapImpl(AttVal first)
 {
     _first = first;
 }
Exemplo n.º 36
0
        /* public method for finding attribute definition by name */
        public virtual Attribute FindAttribute(AttVal attval)
        {
            Attribute np;

            if (attval.Attribute != null)
            {
                np = Lookup(attval.Attribute);
                return np;
            }

            return null;
        }
Exemplo n.º 37
0
 protected internal DomAttrImpl(AttVal adaptee)
     : base(null)
 {
     _attValAdaptee = adaptee;
 }
Exemplo n.º 38
0
 public virtual void Check(Lexer lexer, Node node, AttVal attval)
 {
 }
Exemplo n.º 39
0
        private void PrintAttribute(Out fout, int indent, Node node, AttVal attr)
        {
            string name;
            bool wrappable = false;

            if (_options.IndentAttributes)
            {
                FlushLine(fout, indent);
                indent += _options.Spaces;
            }

            name = attr.Attribute;

            if (indent + linelen >= _options.WrapLen)
            {
                WrapLine(fout, indent);
            }

            if (!_options.XmlTags && !_options.XmlOut && attr.Dict != null)
            {
                if (AttributeTable.DefaultAttributeTable.IsScript(name))
                {
                    wrappable = _options.WrapScriptlets;
                }
                else if (!attr.Dict.Nowrap && _options.WrapAttVals)
                {
                    wrappable = true;
                }
            }

            if (indent + linelen < _options.WrapLen)
            {
                wraphere = linelen;
                AddC(' ', linelen++);
            }
            else
            {
                CondFlushLine(fout, indent);
                AddC(' ', linelen++);
            }

            for (int i = 0; i < name.Length; i++)
            {
                AddC((int) Lexer.FoldCase(name[i], _options.UpperCaseAttrs, _options.XmlTags), linelen++);
            }

            if (indent + linelen >= _options.WrapLen)
            {
                WrapLine(fout, indent);
            }

            if (attr.Val == null)
            {
                if (_options.XmlTags || _options.XmlOut)
                {
                    PrintAttrValue(fout, indent, attr.Attribute, attr.Delim, true);
                }
                else if (!attr.BoolAttribute && !Node.IsNewNode(node))
                {
                    PrintAttrValue(fout, indent, "", attr.Delim, true);
                }
                else if (indent + linelen < _options.WrapLen)
                {
                    wraphere = linelen;
                }
            }
            else
            {
                PrintAttrValue(fout, indent, attr.Val, attr.Delim, wrappable);
            }
        }
Exemplo n.º 40
0
        private void PrintAttrs(Out fout, int indent, Node node, AttVal attr)
        {
            if (attr != null)
            {
                if (attr.Next != null)
                {
                    PrintAttrs(fout, indent, node, attr.Next);
                }

                if (attr.Attribute != null)
                {
                    PrintAttribute(fout, indent, node, attr);
                }
                else if (attr.Asp != null)
                {
                    AddC(' ', linelen++);
                    PrintAsp(fout, indent, attr.Asp);
                }
                else if (attr.Php != null)
                {
                    AddC(' ', linelen++);
                    PrintPhp(fout, indent, attr.Php);
                }
            }

            /* add xml:space attribute to pre and other elements */
            if (_options.XmlOut && _options.XmlSpace && ParserImpl.XMLPreserveWhiteSpace(node, _options.tt) && node.GetAttrByName("xml:space") == null)
            {
                PrintString(fout, indent, " xml:space=\"preserve\"");
            }
        }
Exemplo n.º 41
0
 public Node(short type, byte[] textarray, int start, int end, string element, TagTable tt)
 {
     _parent = null;
     _prev = null;
     _next = null;
     _last = null;
     _start = start;
     _end = end;
     _textarray = textarray;
     _type = type;
     _closed = false;
     _isimplicit = false;
     _linebreak = false;
     _was = null;
     _tag = null;
     _element = element;
     _attributes = null;
     _content = null;
     if (type == StartTag || type == StartEndTag || type == EndTag)
     {
         tt.FindTag(this);
     }
 }
Exemplo n.º 42
0
 public virtual IAttr CreateAttribute(string name)
 {
     AttVal av = new AttVal(null, null, (int) '"', name, null);
     if (av != null)
     {
         av.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(av);
         return (IAttr) av.Adapter;
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 43
0
 public Node(short type, byte[] textarray, int start, int end)
 {
     _parent = null;
     _prev = null;
     _next = null;
     _last = null;
     _start = start;
     _end = end;
     _textarray = textarray;
     _type = type;
     _closed = false;
     _isimplicit = false;
     _linebreak = false;
     _was = null;
     _tag = null;
     _element = null;
     _attributes = null;
     _content = null;
 }
Exemplo n.º 44
0
 protected internal DomAttrMapImpl(AttVal first)
 {
     _first = first;
 }
Exemplo n.º 45
0
        private void MergeStyles(Node node, Node child)
        {
            AttVal av;
            string s1, s2, style;

            for (s2 = null, av = child.Attributes; av != null; av = av.Next)
            {
                if (av.Attribute.Equals("style"))
                {
                    s2 = av.Val;
                    break;
                }
            }

            for (s1 = null, av = node.Attributes; av != null; av = av.Next)
            {
                if (av.Attribute.Equals("style"))
                {
                    s1 = av.Val;
                    break;
                }
            }

            if (s1 != null)
            {
                if (s2 != null)
                {
                    /* merge styles from both */
                    style = MergeProperties(s1, s2);
                    av.Val = style;
                }
            }
            else if (s2 != null)
            {
                /* copy style of child */
                av = new AttVal(node.Attributes, null, '"', "style", s2);
                av.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(av);
                node.Attributes = av;
            }
        }
Exemplo n.º 46
0
        /* create style element using rules from dictionary */
        private void CreateStyleElement(Lexer lexer, Node doc)
        {
            Node node, head, body;
            Style style;
            AttVal av;

            if (lexer.styles == null && NiceBody(lexer, doc))
            {
                return;
            }

            node = lexer.NewNode(Node.StartTag, null, 0, 0, "style");
            node.Isimplicit = true;

            /* insert type attribute */
            av = new AttVal(null, null, '"', "type", "text/css");
            av.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(av);
            node.Attributes = av;

            body = doc.FindBody(lexer.Options.tt);

            lexer.txtstart = lexer.lexsize;

            if (body != null)
            {
                CleanBodyAttrs(lexer, body);
            }

            for (style = lexer.styles; style != null; style = style.Next)
            {
                lexer.AddCharToLexer(' ');
                lexer.AddStringLiteral(style.Tag);
                lexer.AddCharToLexer('.');
                lexer.AddStringLiteral(style.TagClass);
                lexer.AddCharToLexer(' ');
                lexer.AddCharToLexer('{');
                lexer.AddStringLiteral(style.Properties);
                lexer.AddCharToLexer('}');
                lexer.AddCharToLexer('\n');
            }

            lexer.txtend = lexer.lexsize;

            Node.InsertNodeAtEnd(node, lexer.NewNode(Node.TextNode, lexer.lexbuf, lexer.txtstart, lexer.txtend));

            /*
            now insert style element into document head

            doc is root node. search its children for html node
            the head node should be first child of html node
            */

            head = doc.FindHead(lexer.Options.tt);

            if (head != null)
            {
                Node.InsertNodeAtEnd(head, node);
            }
        }
Exemplo n.º 47
0
        public virtual void AddAttribute(string name, string val)
        {
            AttVal av = new AttVal(null, null, null, null, '"', name, val);
            av.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(av);

            if (_attributes == null)
            {
                _attributes = av;
                /* append to end of attributes */
            }
            else
            {
                AttVal here = _attributes;

                while (here.Next != null)
                {
                    here = here.Next;
                }

                here.Next = av;
            }
        }
Exemplo n.º 48
0
		/* swallows closing '>' */
		
		public virtual AttVal ParseAttrs(MutableBoolean isempty)
		{
			AttVal av, list;
			string attribute, val;
			MutableInteger delim = new MutableInteger();
			MutableObject asp = new MutableObject();
			MutableObject php = new MutableObject();
			
			list = null;
			
			while (!EndOfInput())
			{
				attribute = ParseAttribute(isempty, asp, php);
				
				if (attribute == null)
				{
					/* check if attributes are created by ASP markup */
					if (asp.Object != null)
					{
						av = new AttVal(list, null, (Node) asp.Object, null, '\x0000', null, null);
						list = av;
						continue;
					}
					
					/* check if attributes are created by PHP markup */
					if (php.Object != null)
					{
						av = new AttVal(list, null, null, (Node) php.Object, '\x0000', null, null);
						list = av;
						continue;
					}
					
					break;
				}
				
				val = ParseValue(attribute, false, isempty, delim);
				
				if (attribute != null && IsValidAttrName(attribute))
				{
					av = new AttVal(list, null, null, null, delim.Val, attribute, val);
					av.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(av);
					list = av;
				}
				else
				{
					av = new AttVal(null, null, null, null, 0, attribute, val);
					Report.AttrError(this, token, val, Report.BAD_ATTRIBUTE_VALUE);
				}
			}
			
			return list;
		}
Exemplo n.º 49
0
		public virtual AttVal CloneAttributes(AttVal attrs)
		{
			AttVal cattrs = (AttVal) attrs.Clone();
			for (AttVal att = cattrs; att != null; att = att.Next)
			{
				if (att.Asp != null)
					nodeList.Add(att.Asp);
				if (att.Php != null)
					nodeList.Add(att.Php);
			}
			return cattrs;
		}
Exemplo n.º 50
0
 protected internal DomAttrImpl(AttVal adaptee) : base(null)
 {
     _attValAdaptee = adaptee;
 }
Exemplo n.º 51
0
		public virtual void FixHtmlNameSpace(Node root, string profile)
		{
			Node node;
			AttVal prev, attr;
			
			for (node = root.Content; node != null && node.Tag != Options.tt.TagHtml; node = node.Next)
			{
				;
			}
			
			if (node != null)
			{
				prev = null;
				
				for (attr = node.Attributes; attr != null; attr = attr.Next)
				{
					if (attr.Attribute.Equals("xmlns"))
					{
						break;
					}
					
					prev = attr;
				}
				
				if (attr != null)
				{
					if (!attr.Val.Equals(profile))
					{
						Report.Warning(this, node, null, Report.INCONSISTENT_NAMESPACE);
						attr.Val = profile;
					}
				}
				else
				{
					attr = new AttVal(node.Attributes, null, (int) '"', "xmlns", profile);
					attr.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(attr);
					node.Attributes = attr;
				}
			}
		}