当前位置: 首页>>代码示例>>C#>>正文


C# Node.GetAttrByName方法代码示例

本文整理汇总了C#中TidyNet.Node.GetAttrByName方法的典型用法代码示例。如果您正苦于以下问题:C# Node.GetAttrByName方法的具体用法?C# Node.GetAttrByName怎么用?C# Node.GetAttrByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TidyNet.Node的用法示例。


在下文中一共展示了Node.GetAttrByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Check

        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");
                }
            }
        }
开发者ID:bgarrels,项目名称:betterpoeditor,代码行数:30,代码来源:ScriptCheckAttribs.cs

示例2: Check

        public virtual void Check(Lexer lexer, Node node)
        {
            node.CheckUniqueAttributes(lexer);

            /*
                HTML4 strict doesn't allow mixed content for
                elements with %block; as their content model
                */
            if (node.GetAttrByName("width") != null || node.GetAttrByName("height") != null)
            {
                lexer.versions &= ~ HtmlVersion.Html40Strict;
            }
        }
开发者ID:bgarrels,项目名称:betterpoeditor,代码行数:13,代码来源:TableCellCheckTableCheckAttribs.cs

示例3: Check

 public virtual void Check(Lexer lexer, Node node)
 {
     if (node.GetAttrByName("src") != null)
     {
         Report.AttrError(lexer, node, "src", Report.PROPRIETARY_ATTR_VALUE);
     }
 }
开发者ID:AlfieJ,项目名称:TidyNet,代码行数:7,代码来源:HrCheckTableCheckAttribs.cs

示例4: Check

        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");
                }
            }
        }
开发者ID:bgarrels,项目名称:betterpoeditor,代码行数:18,代码来源:LinkCheckTableCheckAttribs.cs

示例5: Check

        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");
            }
        }
开发者ID:AlfieJ,项目名称:TidyNet,代码行数:13,代码来源:StyleCheckTableCheckAttribs.cs

示例6: Check

        public virtual void Check(Lexer lexer, Node node)
        {
            AttVal attval;
            Attribute attribute;
            bool hasSummary = false;

            node.CheckUniqueAttributes(lexer);

            for (attval = node.Attributes; attval != null; attval = attval.Next)
            {
                attribute = attval.CheckAttribute(lexer, node);

                if (attribute == AttributeTable.AttrSummary)
                {
                    hasSummary = true;
                }
            }

            /* suppress warning for missing summary for HTML 2.0 and HTML 3.2 */
            if (!hasSummary && lexer.doctype != HtmlVersion.Html20 && lexer.doctype != HtmlVersion.Html32)
            {
                lexer.badAccess |= Report.MISSING_SUMMARY;
                Report.AttrError(lexer, node, "summary", Report.MISSING_ATTRIBUTE);
            }

            /* convert <table border> to <table border="1"> */
            if (lexer.Options.XmlOut)
            {
                attval = node.GetAttrByName("border");
                if (attval != null)
                {
                    if (attval.Val == null)
                    {
                        attval.Val = "1";
                    }
                }
            }
        }
开发者ID:bgarrels,项目名称:betterpoeditor,代码行数:38,代码来源:TableCheckAttribs.cs

示例7: url

        /*
        move presentation attribs from body to style element

        background="foo" ->  body { background-image: url(foo) }
        bgcolor="foo"    ->  body { background-color: foo }
        text="foo"       ->  body { color: foo }
        link="foo"       ->  :link { color: foo }
        vlink="foo"      ->  :visited { color: foo }
        alink="foo"      ->  :active { color: foo }
        */
        private void CleanBodyAttrs(Lexer lexer, Node body)
        {
            AttVal attr;
            string bgurl = null;
            string bgcolor = null;
            string color = null;

            attr = body.GetAttrByName("background");

            if (attr != null)
            {
                bgurl = attr.Val;
                attr.Val = null;
                body.RemoveAttribute(attr);
            }

            attr = body.GetAttrByName("bgcolor");

            if (attr != null)
            {
                bgcolor = attr.Val;
                attr.Val = null;
                body.RemoveAttribute(attr);
            }

            attr = body.GetAttrByName("text");

            if (attr != null)
            {
                color = attr.Val;
                attr.Val = null;
                body.RemoveAttribute(attr);
            }

            if (bgurl != null || bgcolor != null || color != null)
            {
                lexer.AddStringLiteral(" body {\n");

                if (bgurl != null)
                {
                    lexer.AddStringLiteral("  background-image: url(");
                    lexer.AddStringLiteral(bgurl);
                    lexer.AddStringLiteral(");\n");
                }

                if (bgcolor != null)
                {
                    lexer.AddStringLiteral("  background-color: ");
                    lexer.AddStringLiteral(bgcolor);
                    lexer.AddStringLiteral(";\n");
                }

                if (color != null)
                {
                    lexer.AddStringLiteral("  color: ");
                    lexer.AddStringLiteral(color);
                    lexer.AddStringLiteral(";\n");
                }

                lexer.AddStringLiteral(" }\n");
            }

            attr = body.GetAttrByName("link");

            if (attr != null)
            {
                AddColorRule(lexer, " :link", attr.Val);
                body.RemoveAttribute(attr);
            }

            attr = body.GetAttrByName("vlink");

            if (attr != null)
            {
                AddColorRule(lexer, " :visited", attr.Val);
                body.RemoveAttribute(attr);
            }

            attr = body.GetAttrByName("alink");

            if (attr != null)
            {
                AddColorRule(lexer, " :active", attr.Val);
                body.RemoveAttribute(attr);
            }
        }
开发者ID:AlfieJ,项目名称:TidyNet,代码行数:96,代码来源:Clean.cs

示例8: Style2Rule

        /*
        Find style attribute in node, and replace it
        by corresponding class attribute. Search for
        class in style dictionary otherwise gensym
        new class and add to dictionary.

        Assumes that node doesn't have a class attribute
        */
        private void Style2Rule(Lexer lexer, Node node)
        {
            AttVal styleattr, classattr;
            string classname;

            styleattr = node.GetAttrByName("style");

            if (styleattr != null)
            {
                classname = FindStyle(lexer, node.Element, styleattr.Val);
                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;
                    node.RemoveAttribute(styleattr);
                }
                else
                {
                    /* reuse style attribute for class attribute */
                    styleattr.Attribute = "class";
                    styleattr.Val = classname;
                }
            }
        }
开发者ID:AlfieJ,项目名称:TidyNet,代码行数:37,代码来源:Clean.cs

示例9: CleanWord2000

        /*
        This is a major clean up to strip out all the extra stuff you get
        when you save as web page from Word 2000. It doesn't yet know what
        to do with VML tags, but these will appear as errors unless you
        declare them as new tags, such as o:p which needs to be declared
        as inline.
        */
        public virtual void CleanWord2000(Lexer lexer, Node node)
        {
            /* used to a list from a sequence of bulletted p's */
            Node list = null;

            while (node != null)
            {
                /* discard Word's style verbiage */
                if (node.Tag == _tt.TagStyle || node.Tag == _tt.TagMeta || node.Type == Node.CommentTag)
                {
                    node = Node.DiscardElement(node);
                    continue;
                }

                /* strip out all span tags Word scatters so liberally! */
                if (node.Tag == _tt.TagSpan)
                {
                    node = StripSpan(lexer, node);
                    continue;
                }

                /* get rid of Word's xmlns attributes */
                if (node.Tag == _tt.TagHtml)
                {
                    /* check that it's a Word 2000 document */
                    if (node.GetAttrByName("xmlns:o") == null)
                    {
                        return;
                    }
                }

                if (node.Tag == _tt.TagLink)
                {
                    AttVal attr = node.GetAttrByName("rel");

                    if (attr != null && attr.Val != null && attr.Val.Equals("File-List"))
                    {
                        node = Node.DiscardElement(node);
                        continue;
                    }
                }

                /* discard empty paragraphs */
                if (node.Content == null && node.Tag == _tt.TagP)
                {
                    node = Node.DiscardElement(node);
                    continue;
                }

                if (node.Tag == _tt.TagP)
                {
                    AttVal attr = node.GetAttrByName("class");

                    /* map sequence of <p class="MsoListBullet"> to <ul>...</ul> */
                    if (attr != null && attr.Val != null && attr.Val.Equals("MsoListBullet"))
                    {
                        Node.CoerceNode(lexer, node, _tt.TagLi);

                        if (list == null || list.Tag != _tt.TagUl)
                        {
                            list = lexer.InferredTag("ul");
                            Node.InsertNodeBeforeElement(node, list);
                        }

                        PurgeAttributes(node);

                        if (node.Content != null)
                        {
                            CleanWord2000(lexer, node.Content);
                        }

                        /* remove node and append to contents of list */
                        Node.RemoveNode(node);
                        Node.InsertNodeAtEnd(list, node);
                        node = list.Next;
                    }
                    else if (attr != null && attr.Val != null && attr.Val.Equals("Code"))
                    {
                        /* map sequence of <p class="Code"> to <pre>...</pre> */
                        Node br = lexer.NewLineNode();
                        NormalizeSpaces(lexer, node);

                        if (list == null || list.Tag != _tt.TagPre)
                        {
                            list = lexer.InferredTag("pre");
                            Node.InsertNodeBeforeElement(node, list);
                        }

                        /* remove node and append to contents of list */
                        Node.RemoveNode(node);
                        Node.InsertNodeAtEnd(list, node);
                        StripSpan(lexer, node);
                        Node.InsertNodeAtEnd(list, br);
//.........这里部分代码省略.........
开发者ID:AlfieJ,项目名称:TidyNet,代码行数:101,代码来源:Clean.cs

示例10: PrintAttrs

        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\"");
            }
        }
开发者ID:bgarrels,项目名称:betterpoeditor,代码行数:31,代码来源:PPrint.cs

示例11: FixId

		/* duplicate name attribute as an id */
		public virtual void FixId(Node node)
		{
			AttVal name = node.GetAttrByName("name");
			AttVal id = node.GetAttrByName("id");
			
			if (name != null)
			{
				if (id != null)
				{
					if (!id.Val.Equals(name.Val))
					{
						Report.AttrError(this, node, "name", Report.ID_NAME_MISMATCH);
					}
				}
				else if (Options.XmlOut)
				{
					node.AddAttribute("id", name.Val);
				}
			}
		}
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:21,代码来源:Lexer.cs

示例12: CanPrune

		public virtual bool CanPrune(Node element)
		{
			if (element.Type == Node.TextNode)
				return true;
			
			if (element.Content != null)
				return false;
			
			if (element.Tag == Options.tt.TagA && element.Attributes != null)
				return false;
			
			if (element.Tag == Options.tt.TagP && !Options.DropEmptyParas)
				return false;
			
			if (element.Tag == null)
				return false;
			
			if ((element.Tag.Model & ContentModel.Row) != 0)
				return false;
			
			if (element.Tag == Options.tt.TagApplet)
				return false;
			
			if (element.Tag == Options.tt.TagObject)
				return false;
			
			if (element.Attributes != null && (element.GetAttrByName("id") != null || element.GetAttrByName("name") != null))
				return false;
			
			return true;
		}
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:31,代码来源:Lexer.cs

示例13: CleanTableAttrs

    public virtual void CleanTableAttrs(Node node)
    {
			while (node != null)
			{
				if (node.Tag == _tt.TagTr || node.Tag == _tt.TagTh || node.Tag == _tt.TagTd) //TODO: add tbody?
				{

      AttVal attr;
      string bgurl = null;
      string bgcolor = null;
      string height = null;
      string width = null;
      

      attr = node.GetAttrByName("background");

      if (attr != null)
      {
        bgurl = attr.Val;
        attr.Val = null;
        node.RemoveAttribute(attr);
      }

      attr = node.GetAttrByName("bgcolor");

      if (attr != null)
      {
        bgcolor = attr.Val;
        attr.Val = null;
        node.RemoveAttribute(attr);
      }

      attr = node.GetAttrByName("width");

      if (attr != null)
      {
        width = attr.Val;
        attr.Val = null;
        node.RemoveAttribute(attr);
      }

      attr = node.GetAttrByName("height");

      if (attr != null)
      {
        height = attr.Val;
        attr.Val = null;
        node.RemoveAttribute(attr);
      }

      if (bgurl != null || bgcolor != null || width != null || height != null)
      {
        string style = string.Empty;

        if (bgurl != null)
        {
          style += "background-image:url(" + bgurl + ");";
        }

        if (bgcolor != null)
        {
          style += "background-color:"+ bgcolor +";";
        }

        if (width != null)
        {
          style += "width:" + width + ";";
        }

        if (height != null)
        {
          style += "height:" + height + ";";
        }

        node.AddAttribute("style", style);
      }
        }

        if (node.Content != null)
        {
          CleanTableAttrs(node.Content);
        }
				
        node = node.Next;
      }
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:86,代码来源:Clean.cs

示例14: CleanImgAttrs

    public virtual void CleanImgAttrs(Node node)
    {
      while (node != null)
      {
        if (node.Tag == _tt.TagImg)
        {
          string style = string.Empty;

          AttVal attr = node.GetAttrByName("border");
          if (attr != null)
          {
            style += "border-width:" + attr.Val + ";";
            attr.Val = null;
            node.RemoveAttribute(attr);
          }

          attr = node.GetAttrByName("align");
          if (attr != null)
          {
            style += "float:" + attr.Val + ";";
            attr.Val = null;
            node.RemoveAttribute(attr);
          }

          attr = node.GetAttrByName("height");
          if (attr != null)
          {
            style += "height:" + attr.Val + ";";
            attr.Val = null;
            node.RemoveAttribute(attr);
          }

          attr = node.GetAttrByName("width");
          if (attr != null)
          {
            style += "width:" + attr.Val + ";";
            attr.Val = null;
            node.RemoveAttribute(attr);
          }

          //xhtml requires the alt attribute
          attr = node.GetAttrByName("alt");
          if (attr == null)
          {
            node.AddAttribute("alt", string.Empty);
          }

          attr = node.GetAttrByName("style");
          if (style.Length > 0)
          {
            if (attr != null && !string.IsNullOrEmpty(attr.Val))
            {
              style = style + attr.Val;
              attr.Val = null;
              node.RemoveAttribute(attr);
            }
            node.AddAttribute("style", style);
          } 
        }

        if (node.Content != null)
        {
          CleanImgAttrs(node.Content);
        }

        node = node.Next;
      }
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:68,代码来源:Clean.cs

示例15: CleanAnchorTarget

    public virtual void CleanAnchorTarget(Node node)
    {
      while (node != null)
      {
        if (node.Tag == _tt.TagA)
        {
          AttVal attr = node.GetAttrByName("target");
          if (attr != null)
          {
            if (attr.Val.ToLower() == "_blank")
            {
              AttVal rel = node.GetAttrByName("rel");
              if (rel == null) node.AddAttribute("rel", "external");
              else rel.Val += " external";
            }
            node.RemoveAttribute(attr);
          }
        }

        if (node.Content != null)
        {
          CleanAnchorTarget(node.Content);
        }

        node = node.Next;
      }
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:27,代码来源:Clean.cs


注:本文中的TidyNet.Node.GetAttrByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。