XHTML W3C验证,UTF-8和元标记 [英] XHTML W3C validation, UTF-8 and meta tags

查看:49
本文介绍了XHTML W3C验证,UTF-8和元标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我无法理解我从W3C获得的警告

验证器。在这里,它与源代码一起完全不满足于
。我应该包括哪些元标签?


这是我从W3C验证器得到的警告。


注意:HTTP内容 - 您的网络浏览器发送的类型标题

(未知)不包含charset参数,但

Content-Type是XML text / *子类型之一(text / xml)。

相关规范(RFC 3023)规定了强大的默认值

" us-ascii"对于这些文件,我们将使用此值

,无论您在其他地方指示的编码如何。如果你想使用不同的编码,你应该安排

让你的浏览器发送这个新的编码信息。


这是我的测试文件:


<?xml version =" 1.0" encoding =" UTF-8"?>

<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Strict // EN"

" ; http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

< html lang =" en" xml:lang =" en"

xmlns =" http://www.w3.org/1999/xhtml">

<! - 测试XHTML - >

< head>

< meta http-equiv =" content-type" content =" text / html;

charset = UTF-8" />

< title>示例XHTML< / title>

< / head>

< body>

< div>

< a href =" hello.html"> Hello< / a>再次

< img src =" Hello.gif" ALT ="你好" height =" 121"

width =" 400" />

< form action =" bye-bye /" method =" get">

< div>

< input type =" hidden" name =" config" />

< / div>

< / form>

< ol style =" LIST-STYLE-TYPE:lower-alpha">

< li>一个< / li>

< li>两个< / li>

< / ol>

< / div>

< p>一些扩展字符:& mdash; &安培;阿尔法; & ge;

< / p>

< / body>

< / html>

推荐答案




Zenobia写道:



Zenobia wrote:

I我无法理解我从W3C
验证器得到的警告。在这里,它与源代码一起完全不满意。我应该包含哪些元标记?

以下是我从W3C验证器获得的警告。

注意:Web浏览器发送的HTTP Content-Type标头
(未知)不包含charset参数,但
Content-Type是XML text / *子类型之一(text / xml)。
相关规范(RFC 3023)规定了强有力的默认值
us-ascii。对于这些文件,我们将使用此值
,无论您在其他地方指出的编码如何。如果你想使用不同的编码,你应该安排
让你的浏览器发送这个新的编码信息。

这是我的测试文件:

<?xml version =" 1.0" encoding =" UTF-8"?>
<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Strict // EN"
" http://www.w3 .org / TR / xhtml1 / DTD / xhtml1-strict.dtd">
< html lang =" en" xml:lang =" en"
xmlns =" http://www.w3.org/1999/xhtml">
<! - 测试XHTML - >
< head>
< meta http-equiv =" content-type" content =" text / html;
charset = UTF-8" />
I can''t understand the warning I''m getting from the W3C
validator. Here it is, along with the source code that it is not
fully satisfied with. What meta-tags should I be including?

Here is the warning I got from the W3C validator.

Note: The HTTP Content-Type header sent by your web browser
(unknown) did not contain a "charset" parameter, but the
Content-Type was one of the XML text/* sub-types (text/xml). The
relevant specification (RFC 3023) specifies a strong default of
"us-ascii" for such documents so we will use this value
regardless of any encoding you may have indicated elsewhere. If
you would like to use a different encoding, you should arrange
to have your browser send this new encoding information.

Here is my test file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en"
xmlns="http://www.w3.org/1999/xhtml">
<!-- Test XHTML -->
<head>
<meta http-equiv="content-type" content="text/html;
charset=UTF-8" />




您正在使用文件上传验证,对吗?我担心,如果您想要验证您的XHTML,那么如果您第一次使用,那么最好将
通过FTP上传到公共HTTP服务器,然后通过<验证br />
给出W3C验证器的URL。然后W3C验证器读取我认为找到编码的

XML声明,你不会收到警告。

-


Martin Honnen
http://JavaScript.FAQTs.com/



Your are using the file upload validation, right? I am afraid that if
you want to validate your XHTML then you are better off if you first
upload the file via FTP to a public HTTP server and then validate by
giving the URL to the W3C validator. Then the W3C validator reads the
XML declaration I think to find the encoding and you don''t get that warning.
--

Martin Honnen
http://JavaScript.FAQTs.com/





Zenobia写道:



Zenobia wrote:

我无法理解我从W3C
验证器得到的警告。在这里,它与源代码一起完全不满意。我应该包含哪些元标记?

以下是我从W3C验证器获得的警告。

注意:Web浏览器发送的HTTP Content-Type标头
(未知)不包含charset参数,但
Content-Type是XML text / *子类型之一(text / xml)。
相关规范(RFC 3023)规定了强有力的默认值
us-ascii。对于这些文件,我们将使用此值
,无论您在其他地方指出的编码如何。如果你想使用不同的编码,你应该安排
让你的浏览器发送这个新的编码信息。

这是我的测试文件:

<?xml version =" 1.0" encoding =" UTF-8"?>
<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Strict // EN"
" http://www.w3 .org / TR / xhtml1 / DTD / xhtml1-strict.dtd">
< html lang =" en" xml:lang =" en"
xmlns =" http://www.w3.org/1999/xhtml">
<! - 测试XHTML - >
< head>
< meta http-equiv =" content-type" content =" text / html;
charset = UTF-8" />
I can''t understand the warning I''m getting from the W3C
validator. Here it is, along with the source code that it is not
fully satisfied with. What meta-tags should I be including?

Here is the warning I got from the W3C validator.

Note: The HTTP Content-Type header sent by your web browser
(unknown) did not contain a "charset" parameter, but the
Content-Type was one of the XML text/* sub-types (text/xml). The
relevant specification (RFC 3023) specifies a strong default of
"us-ascii" for such documents so we will use this value
regardless of any encoding you may have indicated elsewhere. If
you would like to use a different encoding, you should arrange
to have your browser send this new encoding information.

Here is my test file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en"
xmlns="http://www.w3.org/1999/xhtml">
<!-- Test XHTML -->
<head>
<meta http-equiv="content-type" content="text/html;
charset=UTF-8" />




您正在使用文件上传验证,对吗?我担心,如果您想要验证您的XHTML,那么如果您第一次使用,那么最好将
通过FTP上传到公共HTTP服务器,然后通过<验证br />
给出W3C验证器的URL。然后W3C验证器读取我认为找到编码的

XML声明,你不会收到警告。

-


Martin Honnen
http://JavaScript.FAQTs.com/



Your are using the file upload validation, right? I am afraid that if
you want to validate your XHTML then you are better off if you first
upload the file via FTP to a public HTTP server and then validate by
giving the URL to the W3C validator. Then the W3C validator reads the
XML declaration I think to find the encoding and you don''t get that warning.
--

Martin Honnen
http://JavaScript.FAQTs.com/


On Sun,2004年4月11日,Zenobia写道:
On Sun, 11 Apr 2004, Zenobia wrote:
我应该包括哪些元标记?


可能是错误的问题。 HTTP协议不包含meta

标签。

这是我从W3C验证器得到的警告。

注意:您的Web浏览器发送的HTTP Content-Type标头
^^^^^^^^^^^^^^^^^^^^^^^^(未知)不包含charset ;参数,但
Content-Type是XML text / *子类型之一(text / xml)。


我认为您通过上传

a本地文件提交了您的内容以进行验证,而不是通过向验证者提供一个它可以的网址

访问你自己的系统?


验证者警告你它收到了提交而没有

浏览器告诉它什么字符编码(" ; charset")浏览器

认为它正在使用。这实际上是非常常见的浏览器

行为,由于遗留原因,虽然通过权利 - 作为验证者

向您解释 - 收件人有权假设我们 - ascii in

这个上下文除非浏览器明确告诉它。


在这个特定的实例中,你的源代码实际上包含

只有us-ascii字符,警告是无害的。既然us-ascii是utf-8编码的
a子集,那么让XML确保它是utf-8就不会有害。


你可以通过重命名本地文件来暗示HTML

而不是XML来欺骗验证器。这是一个杂耍行为,因为W3C试图实现不可能的麻烦,并且无条件地转换到XHTML - 并且使事情变得棘手比他们从一开始就坚持大爆炸的情况要糟糕得多。臭名昭着的

" XHTML / 1.0附录C"只是这个烂摊子的一部分。


或者更有用(特别是如果你想让别人帮你建设性的话),你可以把测试材料放在上面一个可以访问网页的
服务器(检查服务器发送适当的HTTP内容

标题,当它提供内容时),然后通过URL提交它

而不是上传。

这是我的测试文件:
What meta-tags should I be including?
Probably the wrong question. HTTP protocol doesn''t consist of "meta
tags".
Here is the warning I got from the W3C validator.

Note: The HTTP Content-Type header sent by your web browser ^^^^^^^^^^^^^^^^^^^^^^^^ (unknown) did not contain a "charset" parameter, but the
Content-Type was one of the XML text/* sub-types (text/xml).
I take it that you submitted your content for validation by uploading
a local file, rather than by giving the validator a URL which it could
access on your own system?

The validator is warning you that it received the submission without
the browser telling it what character encoding ("charset") the browser
thought it was using. This is actually quite common browser
behaviour, for legacy reasons, although by rights - as the validator
is explaining to you - the recipient is entitled to assume us-ascii in
this context unless the browser explicitly tells it otherwise.

In this particular instance, where your source code in fact contains
only us-ascii characters, the warning is harmless. Since us-ascii is
a subset of utf-8 encoding, you''re doing no harm by letting XML
believe that it''s utf-8.

You could fool the validator by renaming the local file to imply HTML
rather than XML. It''s a bit of a juggling act, due to the messy
consequences of the W3C trying to achieve the impossible and make a
seamless transition to XHTML - and making matters a lot worse than if
they''d insisted on the big bang right from the outset. The notorious
"XHTML/1.0 Appendix C" is only part of this mess.

Or more usefully (and especially if you want others to help you
constructively), you could put the test material on a web-accessible
server (checking that the server sends an appropriate HTTP content
header when it serves the content out), and then submit it by URL
rather than by upload.
Here is my test file:




是的,但这并没有真正帮助,因为如果我保存为foobar.html

并提交它,那么验证器就没有投诉。


但是,如果我将它重命名为foob​​ar.xml并提交-that-,然后

验证器弹出这个警告。


不幸的是,似乎验证人员已经实现了这个

有意提供信息的警告,但实际上并未将其记录下来。

记录它。至少,我在他们的文档中找不到任何进一步的解释(谷歌也没有,尽管它在邮件列表档案中发现了几个有用的讨论) [1]


其他贡献者可能会得到不同的效果,具体取决于他们使用哪种浏览器/文件扩展名/

内容类型映射已设置。


这是非常可取的(如同这组重复推荐的那样)

如果你可以放样本一个网络服务器,并告诉Hon

Usenauts它的URL。


祝你好运


[1] As一般提示:当你对他们的意思有疑问时,不要害怕输入错误信息片段

逐字输入谷歌。在

这种情况​​下,它并没有那么有用,但总的来说它会给你一个快速回答而无需等待来自

usenet。



Yes, but that doesn''t really help, since if I save that as foobar.html
and submit it, there''s no complaints from the validator.

However, if I rename it to foobar.xml and submit -that-, then the
validator pops up with this warning.

Unfortunately, it seems that the validator folk have implemented this
intended-to-be-informative warning without actually getting around to
documenting it. At least, I couldn''t find any further explanation in
their documentation (nor could Google, though it found a couple of
useful discussions on the mailing list archives)[1]

Other contributors may get different effects depending on which
browser they use, and how their browser/ filename-extension/
content-type mappings are set.

It really is much preferable (as repeatedly recommended on this group)
if you can put your specimen on a web server, and tell the hon
Usenauts its URL.

good luck

[1] As a general tip: don''t be afraid to type error message fragments
verbatim into Google when you''re in doubt as to what they mean. In
this case, it wasn''t as helpful as it might be, but in general it
rates to give you a quick answer without waiting for a response from
usenet.


这篇关于XHTML W3C验证,UTF-8和元标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆