2

<body>中,受控词汇可以按如下方式初始化:

<!DOCTYPE html>
<html
  lang="en"
  xml:lang="en"
  xmlns="http://www.w3.org/1999/xhtml"
>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title></title>
</head>
<body prefix="
  bibo: http://purl.org/ontology/bibo/
  cc: http://creativecommons.org/ns#
  dc: http://purl.org/dc/terms/
  foaf: http://xmlns.com/foaf/0.1/
  schema: http://schema.org/
">

采用类似的方法在 中使用受控词汇表是否可以接受(并且是一种良好的编程实践)<head>?例如:

<!DOCTYPE html>
<html
  lang="en"
  xml:lang="en"
  xmlns="http://www.w3.org/1999/xhtml"
>
<head prefix="
  bibo: http://purl.org/ontology/bibo/
  cc: http://creativecommons.org/ns#
  dc: http://purl.org/dc/terms/
  foaf: http://xmlns.com/foaf/0.1/
  schema: http://schema.org/
">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta dc:author content="fname_lname" />
<meta schema:dateCreated content="yy-mm-dd" />
<meta bibo:Website href="http://www.example.com" />
<link foaf:Person href="https://plus.google.com/u/0/_Google_mbox_string_/about" rel="publisher" />
<title></title>
</head>
4

1 回答 1

3

是的,您可以prefix任何元素上使用。前缀将应用于后代元素;因此,如果您指定prefixon head,则不能将这些前缀用于body.

如果要在整个文档中使用相同的前缀,则可能需要使用html元素。

以防万一您不知道:您不必为RDFa Core Initial Context中定义的词汇表指定前缀。只要您使用已注册的前缀(并且您没有为文档中的其他内容定义这些前缀),您就可以使用foafschema而不使用prefix/ vocab

于 2014-04-26T14:28:31.350 回答