當前位置: 首頁>>代碼示例>>C#>>正文


C# Node.FindDocType方法代碼示例

本文整理匯總了C#中TidyNet.Node.FindDocType方法的典型用法代碼示例。如果您正苦於以下問題:C# Node.FindDocType方法的具體用法?C# Node.FindDocType怎麽用?C# Node.FindDocType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TidyNet.Node的用法示例。


在下文中一共展示了Node.FindDocType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FixDocType

		/* fixup doctype if missing */
		public virtual bool FixDocType(Node root)
		{
			Node doctype;
			HtmlVersion guessed = HtmlVersion.Html40Strict;
			int i;
			
			if (this.badDoctype)
			{
				Report.Warning(this, null, null, Report.MALFORMED_DOCTYPE);
			}
			
			if (Options.XmlOut)
			{
				return true;
			}
			
			doctype = root.FindDocType();
			
			if (Options.DocType == TidyNet.DocType.Omit)
			{
				if (doctype != null)
				{
					Node.DiscardElement(doctype);
				}
				return true;
			}
			
			if (Options.DocType == TidyNet.DocType.Strict)
			{
				Node.DiscardElement(doctype);
				doctype = null;
				guessed = HtmlVersion.Html40Strict;
			}
			else if (Options.DocType == TidyNet.DocType.Loose)
			{
				Node.DiscardElement(doctype);
				doctype = null;
				guessed = HtmlVersion.Html40Loose;
			}
			else if (Options.DocType == TidyNet.DocType.Auto)
			{
				if (doctype != null)
				{
					if (this.doctype == HtmlVersion.Unknown)
					{
						return false;
					}

					switch (this.doctype)
					{
					case HtmlVersion.Unknown:
						return false;

					case HtmlVersion.Html20:
						if ((this.versions & HtmlVersion.Html20) != 0)
						{
							return true;
						}
						break; /* to replace old version by new */
						
						
					case HtmlVersion.Html32:
						if ((this.versions & HtmlVersion.Html32) != 0)
						{
							return true;
						}
						break; /* to replace old version by new */
						
						
					case HtmlVersion.Html40Strict:
						if ((this.versions & HtmlVersion.Html40Strict) != 0)
						{
							return true;
						}
						break; /* to replace old version by new */
						
						
					case HtmlVersion.Html40Loose:
						if ((this.versions & HtmlVersion.Html40Loose) != 0)
						{
							return true;
						}
						break; /* to replace old version by new */
						
						
					case HtmlVersion.Frames:
						if ((this.versions & HtmlVersion.Frames) != 0)
						{
							return true;
						}
						break; /* to replace old version by new */
					}
					
					/* INCONSISTENT_VERSION warning is now issued by ApparentVersion() */
				}
				
				/* choose new doctype */
				guessed = GetHtmlVersion();
			}
//.........這裏部分代碼省略.........
開發者ID:erikzaadi,項目名稱:atomsitethemes.erikzaadi.com,代碼行數:101,代碼來源:Lexer.cs

示例2: SetXhtmlDocType

		public virtual bool SetXhtmlDocType(Node root)
		{
			string fpi = " ";
			string sysid = "";
			string namespace_Renamed = XHTML_NAMESPACE;
			Node doctype;
			
			doctype = root.FindDocType();
			
			if (Options.DocType == TidyNet.DocType.Omit)
			{
				if (doctype != null)
					Node.DiscardElement(doctype);
				return true;
			}
			
			if (Options.DocType == TidyNet.DocType.Auto)
			{
				/* see what flavor of XHTML this document matches */
				if ((this.versions & HtmlVersion.Html40Strict) != 0)
				{
					/* use XHTML strict */
					fpi = "-//W3C//DTD XHTML 1.0 Strict//EN";
					sysid = voyager_strict;
				}
				else if ((this.versions & HtmlVersion.Loose) != 0)
				{
					fpi = "-//W3C//DTD XHTML 1.0 Transitional//EN";
					sysid = voyager_loose;
				}
				else if ((this.versions & HtmlVersion.Frames) != 0)
				{
					/* use XHTML frames */
					fpi = "-//W3C//DTD XHTML 1.0 Frameset//EN";
					sysid = voyager_frameset;
				}
				else
				{
					/* lets assume XHTML transitional */
					fpi = "-//W3C//DTD XHTML 1.0 Transitional//EN";
					sysid = voyager_loose;
				}
			}
			else if (Options.DocType == TidyNet.DocType.Strict)
			{
				fpi = "-//W3C//DTD XHTML 1.0 Strict//EN";
				sysid = voyager_strict;
			}
			else if (Options.DocType == TidyNet.DocType.Loose)
			{
				fpi = "-//W3C//DTD XHTML 1.0 Transitional//EN";
				sysid = voyager_loose;
			}
			
			FixHtmlNameSpace(root, namespace_Renamed);
			
			if (doctype == null)
			{
				doctype = NewNode(Node.DocTypeTag, this.lexbuf, 0, 0);
				doctype.Next = root.Content;
				doctype.Parent = root;
				doctype.Prev = null;
				root.Content = doctype;
			}
			
			if (Options.DocType == TidyNet.DocType.User && Options.DocTypeStr != null)
			{
				fpi = Options.DocTypeStr;
				sysid = "";
			}
			
			this.txtstart = this.lexsize;
			this.txtend = this.lexsize;
			
			/* add public identifier */
			AddStringLiteral("html PUBLIC ");
			
			/* check if the fpi is quoted or not */
			if (fpi[0] == '"')
			{
				AddStringLiteral(fpi);
			}
			else
			{
				AddStringLiteral("\"");
				AddStringLiteral(fpi);
				AddStringLiteral("\"");
			}
			
			if (sysid.Length + 6 >= this.Options.WrapLen)
			{
				AddStringLiteral("\n\"");
			}
			else
			{
				AddStringLiteral("\n    \"");
			}

			/* add system identifier */
			AddStringLiteral(sysid);
//.........這裏部分代碼省略.........
開發者ID:erikzaadi,項目名稱:atomsitethemes.erikzaadi.com,代碼行數:101,代碼來源:Lexer.cs


注:本文中的TidyNet.Node.FindDocType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。