HTML Tidy 检查和 SGML 解析器检查对于 XHTML 合规性都是必需的吗?
如果我想要严格遵守 XHTML,并且我的标头如下:
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
如果我通过了 HTML Tidy 检查,那么考虑到我想要遵守 XHTML,SGML 解析器检查是否也是必要的? (我没有真正的理由这样做,我只是很挑剔,直到我有理由不那么挑剔为止。)当我查看 Firefox 插件验证器的“清理”建议输出时,它给出了以下代码:缺少 标记的结束部分。
<form method="post" action="set_anonymous">
<input type="submit" value="Be anonymous">
</form>
这种“清理”的代码是否表明我使用验证器不当?
If I want to be XHTML strict and my headers are as follows:
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
If I pass the HTML Tidy check is the SGML Parser check also necessary given that I want to be XHTML compliant? (I have no real reason for this, I'm just being fussy until I have a reason to be less fussy.) When I look at the "Cleanup" suggested output from the Firefox plug-in validator, it gives the following code that is missing the closing part of the <input>
tag.
<form method="post" action="set_anonymous">
<input type="submit" value="Be anonymous">
</form>
Does this kind of "cleaned up" code suggest I am using the validator improperly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你尝试过走另一条路吗? XHTML 文档是纯 XML 文件,其架构在 dtd 文件中定义。
这意味着任何 xml 验证器都可以告诉您文档是否有效。
您可以通过以下方式验证文档是否正确:
下载 XMLstarlet。
转至 XHTML dtd 页面 并下载这些文件:
xhtml1-strict。 dtd
xhtml-lat1.ent
xhtml-special.ent
xhtml-symbol.ent
将它们全部放在一个文件夹中。在该文件夹中,放入您的 XHTML 文档(我们称之为
test.xhtml
)并运行以下命令:如果您的响应是“test.xhtml - valid”,那么您就获得了一个有效的文档。
如果没有,
-e
标志会告诉您出了什么问题。Have you tried going the other way? XHTML documents are plain XML files and their schema is defined in a dtd file.
That means any xml validator can tell you if your document is valid or not.
This is how you can validate if a document is proper:
Download XMLstarlet.
Go to XHTML dtd page and download these files:
xhtml1-strict.dtd
xhtml-lat1.ent
xhtml-special.ent
xhtml-symbol.ent
put them all in one folder. Inside that folder, put your XHTML document (let's call it
test.xhtml
) and run the following command:If your response is "test.xhtml - valid", you've got a valid document.
If not, the
-e
flag will tell you what went wrong.