元素名称gcse:searchbox-only不能表示为XML 1.0 [英] Element name gcse:searchbox-only cannot be represented as XML 1.0

查看:118
本文介绍了元素名称gcse:searchbox-only不能表示为XML 1.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在w3验证程序中出现以下错误:

 第62行,第140列:元素名称gcse:仅限searchbox不能表示为XML 1.0。 

我在使用此代码添加的网站内部的Google搜索栏,

 < gcse:searchbox-only>< / gcse:searchbox-only> 

请帮助避免此错误。谢谢

解决方案

Michael [tm] Smith,照顾W3C HTML验证器的人在此说明


这不是一个错误,这是一个警告。它的发布是因为
内容被用作HTML而不是XML MIME类型,而
HTML解析器不知道任何关于名称空间的内容 - 以XML
的形式表示,每个元素名称都是本地名称 - 所以在HTML中,该元素的
文字名称是g:plusone。并且该名称不能用XML表示,因为XML不允许冒号在本地
名称中。因此,警告的精神在于,如果您希望
将此内容作为XML而不是HTML来提供,那么您的元素名称为
,而XML中不允许这样做。


他在谈论元素 g:plusone ,但它是同样的问题。



但我不同意。 XML 1.0 中的冒号在元素本地名称中有效。它们仅在中被禁止。因此,警告消息可以肯定会有所改进。

更新:
我以前提供了一个基于document.write的解决方法,但是正如Jan M在评论中指出的那样,IE有它自己有关如何处理标记名称中带有冒号的元素的想法,所以它在那里不起作用。相反,我建议遵循Jan的答案。

I am getting the following error in w3 validator,

 Line 62, Column 140: Element name gcse:searchbox-only cannot be represented as XML 1.0.

I am using Google search bar inside website which is added by this code,

<gcse:searchbox-only></gcse:searchbox-only>

Please help out to avoid this error. Thanks

Michael[tm] Smith, the guy who looks after the W3C HTML validator says here:

It's not an error, it's a warning. And it's emitted because the content is being served as HTML instead of with an XML MIME type, and HTML parsers don't know anything about namespaces -- to put it in XML terms, every element name is a local name -- and so in HTML, the literal name of that element is "g:plusone". And that name can't be represented in XML because XML doesn't allow colons in the local names. So the spirit of the warning is to say, In case you ever want to serve this content as XML instead of HTML, you have an element name in it that's not allowed in XML.

He's talking about the element g:plusone but it's the same issue.

But I disagree slightly. Colons are valid in element local names in XML 1.0. They're only disallowed in XML 1.0 + namespaces So the warning message could definitely be improved.

UPDATE: I previously offered a workaround based on document.write, but as Jan M points out in the comments, IE has it's own ideas about what to do with elements with a colon in their tag names, so it didn't work there. Instead, I recommend following Jan's answer.

这篇关于元素名称gcse:searchbox-only不能表示为XML 1.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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