1

我无法让我的网站在 W3C 标记验证中进行验证。

这是验证错误之一的示例。

Error: Attribute xmlns:content not allowed here.

我做了一些研究,一些文章建议我们改变:
xmlns:name="http://url" syntax into the prefix="name:http://url"

但是我有多个 xmlns 属性。
不确定在这种情况下如何编写前缀。

原来的:

`<html lang="en" dir="ltr"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:dc="http://purl.org/dc/terms/"
  xmlns:foaf="http://xmlns.com/foaf/0.1/"
  xmlns:og="http://ogp.me/ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xmlns:sioc="http://rdfs.org/sioc/ns#"
  xmlns:sioct="http://rdfs.org/sioc/types#"
  xmlns:skos="http://www.w3.org/2004/02/skos/core#"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema#">`

每个属性之间是否用空格隔开?

<html lang="en" dir="ltr" prefix="content:http://purl.org/rss/1.0/modules/content/ dc:http://purl.org/dc/terms/ foaf:http://xmlns.com/foaf/0.1/">

或者我们应该用\n新行分开?
我已经检查了 w3.org 网站,看起来他们将属性分隔在新行中。
我对吗?
http://www.w3.org/TR/2011/WD-rdfa-core-20111215/

4

3 回答 3

1

您不能在 HTML 5 中使用任意命名空间中的元素。为此,您需要使用 XML,并且为了验证,您需要一个合适的 DTD 或包含您要使用的所有命名空间的模式。

于 2013-08-13T09:07:08.390 回答
0

你需要一个 doctype 放在你的 html 标签之前。您可以使用:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
于 2013-01-14T10:21:43.447 回答
0

网页包含 RDFa 标记,这在 HTML 5 中是允许的。HTML+RDFa 1.1 规范一个专门用于@xmlns:属性的部分。

它说@xmlns:在 RDFa 1.1 中不推荐使用 ,但仍然允许向后兼容。因此,如果可能,不应该使用它。然后,关于@xmlns:-Prefixed Attributes 的一致性标准的以下部分表明:

对于符合本规范的文档,名称具有不区分大小写的前缀匹配“ @xmlns:”的属性必须被视为符合。一致性检查器应该接受具有不区分大小写前缀匹配“ @xmlns:”的属性名称作为符合。一致性检查器应该生成警告,指出@xmlns:不推荐使用 。一致性检查器可以将使用报告xmlns:为错误。

我知道 W3C HTML 验证器正在采用更严格的一致性检查,其中xmlns:报告为错误,尽管我觉得这很奇怪,因为它应该生成警告。

于 2015-12-25T09:40:50.813 回答