HTML前缀属性的含义(开放图谱协议)? [英] Meaning of HTML prefix attribute (Open Graph Protocol)?

查看:123
本文介绍了HTML前缀属性的含义(开放图谱协议)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Facebook开放图协议的新手.我一直在尝试弄清楚HTML prefix属性的含义是什么.我可以找到有关此主题的最接近Stack Overflow的帖子是

I'm new to Facebook Open Graph Protocol. I have been trying to figure out what the meaning of the HTML prefix attribute is. The closest post on Stack Overflow I could find dealing with this subject is this post which was very helpful as it deals with what the differences are among the various possible syntaxes and which one to use.

但是,该帖子未说明此prefix属性是什么或它做什么. AFAIK,这不是标准的HTML属性.我可以找到我认为的此文档是W3C定义此属性的地方,但无法理解它.

However the post does not say anything about what this prefix attribute is or what it does. AFAIK this is not a standard HTML attribute. I was able to find this document which I think is where the W3C defines this attribute but was not able to make any sense of it.

有人可以向我解释吗?

  1. prefix属性的作用是什么?

我可以写

<html prefix="og:http://ogp.me/ns#">

代替

<html prefix="og: http://ogp.me/ns#">

还是语法错误?

我可以为任何给定的HTML标签包括多个prefix属性吗?

Can I include multiple prefix attributes for any given HTML tag?

<head prefix="a: http://www.aaa.com/ns#" prefix="b: http://www.bbb.com/ns#">

根据我对HTML的了解,这是错误的,但是prefix是非标准属性.所以也许,我想知道的是,我可以写:

Based on my knowledge of HTML, this would be wrong, but then prefix is a nonstandard attribute. So perhaps, what I would like to know is, can I write:

<head prefix="a: http://www.aaa.com/ns# b: http://www.bbb.com/ns#">

还是出于某种原因在HTML树的任何位置指定多个前缀都没有意义?

or does specifying multiple prefixes at any place in the HTML tree not make sense for some reason?

如果此prefix标记不是HTML规范的一部分,那么将包含此属性的页面提交给代码验证器怎么会导致我的代码符合标准?

If this prefix tag is not part of the HTML spec, how would submitting a page containing this attribute to a code validator ever result in my code being standards compliant?

谢谢您回答我的问题.

推荐答案

首先:

prefix RDFa(属性中的资源描述框架)定义的属性的一个 扩展名. RDFa 用于在许多代表的网页中实现语义网标记语言,例如HTML和XML.现在,您无需告诉网页浏览器应该如何构造网页,而是还可以告诉它网页代表什么,例如人员,产品列表等.

prefix is one of the attributes defined by the RDFa (Resource Description Framework in Attributes) extension. RDFa is used to implement the Semantic Web in web pages represented in many markup languages, like HTML and XML. Instead of having a web page telling the browser just how it should be structured, now you can also tell it what the page represents, like a Person, a List of Products, etc.

要使您能够在语义上表示网页上的数据,您需要使用语义词汇表,它可以告诉浏览器确切的信息:页面中所表示的内容.流行的语义词汇表 schema.org .

And for you to be able to semantically represent data on your web page, you need to use a semantic vocabulary, which tells the browser exactly that: what's being represented in your page. A popular semantic vocabulary is schema.org.

但是有时候,一个单一的语义词汇不能代表和描述您的所有网页.这就是prefix属性出现的位置:

But sometimes a singular semantic vocabulary cannot represent and describe all of your web page. That's where the prefix attribute comes in:

prefix属性的作用是什么?

What does the prefix attribute do?

prefix属性允许您指定一个或多个正在使用的语义词汇.下面的示例使用两个词汇来表示具有最喜欢的动物一个人: schema.org vocab.org .

The prefix attribute allows you to specify one or more semantic vocabularies being used. The following example uses two vocabularies to represent a Person that has a favorite Animal: schema.org and vocab.org.

<p vocab="http://schema.org/" prefix="ov: http://open.vocab.org/terms/" resource="#manu" typeof="Person">
    My name is <span property="name">MY_NAME</span>

    and my telephone is <span property="telephone">MY_TELEPHONE</span>.

    My favorite animal is the <span property="ov:preferredAnimal">FAVORITE_ANIMAL</span>.
</p>

我可以写<html prefix="og:http://ogp.me/ns#">而不是<html prefix="og: http://ogp.me/ns#">还是语法错误?

Can I write <html prefix="og:http://ogp.me/ns#"> instead of <html prefix="og: http://ogp.me/ns#"> or would that be a syntax error?

除了不能使用以前的语法在网络上找到任何示例之外,还

Besides from not being able to find any examples on the web using the former syntax, from the specification of the RDFa Core you can see that at least one space is indeed mandatory:

prefix
    a white space separated list of prefix-name IRI pairs of the form
    NCName ':' ' '+ xsd:anyURI

我可以为任何给定的HTML标签包括多个prefix属性吗?

是的,可以.根据上面给出的prefix属性的规范,以及根据 RDFa Core ,则允许以下操作:

Yes, you can. From the specification of the prefix attribute given above, and from lots of examples given on the specification of the RDFa Core, the following is allowed:

<html
    prefix="foaf: http://xmlns.com/foaf/0.1/
            dc: http://purl.org/dc/terms/"
>
    <!-- your page -->
</html>

如果此prefix标记不是HTML规范的一部分,那么将包含此属性的页面提交给代码验证器怎么会导致我的代码符合标准?

If this prefix tag is not part of the HTML spec, how would submitting a page containing this attribute to a code validator ever result in my code being standards compliant?

如@wensveen所述, HTML5支持现成的RDFa属性.

As mentioned by @wensveen, HTML5 supports the RDFa attributes out-of-the-box.

这篇关于HTML前缀属性的含义(开放图谱协议)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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