本文整理汇总了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();
}
//.........这里部分代码省略.........
示例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);
//.........这里部分代码省略.........