本文介绍了XHTML 1.1验证错误:“参数实体'xhtml-inlstyle.mod'引用了自己”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,我尝试使用官方dtd验证我的html页面:
Hey I try to validate my html page with official dtd :
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(MessageBody));
ms.Position = 0;
XmlReaderSettings settingsReader = new XmlReaderSettings();
settingsReader.DtdProcessing = DtdProcessing.Parse;
settingsReader.ValidationType = ValidationType.DTD;
MyUrlResolver resolver = new MyUrlResolver();
settingsReader.XmlResolver = resolver;
XmlReader reader = XmlReader.Create(ms, settingsReader);
while(reader.Read()){}
和自定义XmlUrlResolver:
and custom XmlUrlResolver:
class MyUrlResolver : System.Xml.XmlUrlResolver
{
public MyUrlResolver()
{ }
public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
{
if (File.Exists(System.Web.Hosting.HostingEnvironment.MapPath("~/dtd/xhtml11.dtd")))
{
absoluteUri = new Uri(System.Web.Hosting.HostingEnvironment.MapPath("~/dtd/xhtml11.dtd"));
}
return base.GetEntity(absoluteUri, role, ofObjectToReturn);
}
public override Uri ResolveUri(Uri baseUri, string relativeUri)
{
baseUri = new Uri(System.Web.Hosting.HostingEnvironment.MapPath("~"));
relativeUri = "dtd/xhtml11.dtd";
return base.ResolveUri(baseUri, relativeUri);
}
}
在阅读xml时发生验证,并且出现异常:
Durning reading xml occurs validation and I get exception:
此处发生错误:
<!-- Inline Style Module ........................................ -->
<!ENTITY % xhtml-inlstyle.module "INCLUDE" >
<![%xhtml-inlstyle.module;[
<!ENTITY % xhtml-inlstyle.mod
PUBLIC "-//W3C//ELEMENTS XHTML Inline Style 1.0//EN"
"http://www.w3.org/MarkUp/DTD/xhtml-inlstyle-1.mod" >
%xhtml-inlstyle.mod;]]>
我不明白为什么官方dtd是错误的:/我应该怎么做?
I cannot understand why official dtd is wrong :/ What should I do ?
推荐答案
对我来说,解决方案是下载xhtml11.dtd和所有引用到dtd的* .mod文件。然后,我在dtd中删除http链接到
Solution for me was download xhtml11.dtd and all *.mod files referenced to dtd. Then I in dtd remove http links to
<!ENTITY % xhtml-datatypes.module "INCLUDE" >
<![%xhtml-datatypes.module;[
<!ENTITY % xhtml-datatypes.mod
PUBLIC "-//W3C//ENTITIES XHTML Datatypes 1.0//EN"
"xhtml-datatypes-1.mod" >
%xhtml-datatypes.mod;]]>
现在在验证html页面中的dtd可以使用本地dtd,而无需从www下载;)
Now dtd during validation html page can use local dtd without download it from www ;)
这篇关于XHTML 1.1验证错误:“参数实体'xhtml-inlstyle.mod'引用了自己”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!