rdf:resource、rdf:about 和 rdf:ID 之间的差异 [英] Differences between rdf:resource, rdf:about and rdf:ID

查看:44
本文介绍了rdf:resource、rdf:about 和 rdf:ID 之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

rdf:resourcerdf:aboutrdf:ID 在概念上有什么区别.我做了一些调查,但我还不清楚它们之间的区别.例如,在第一次声明资源时是否使用 rdf:IDrdf:resource 是否用于引用已经存在的资源等.

What are the conceptual differences between rdf:resource, rdf:about, and rdf:ID. I did some investigation but the difference between them are not clear for me yet. For example, whether rdf:ID is used when declaring a resource for the first time, rdf:resource is used for referencing an already existing resource, etc.

如果你能提供一些小例子,我会很高兴.

I would be glad if you provide some little examples.

推荐答案

需要明确的是,这只是关于编写 rdf 的一种特定方式:即 RDF/XML.其他语法没有这些差异.

To be clear this is only about a particular way of writing rdf: namely RDF/XML. Other syntaxes don't feature these differences.

免责声明:

我们要做的是编写以下形式的语句:

What we're trying to do is write statements of the form:

subject predicate object

特别是:

subjectURI predicate objectURI

那么我们如何在 RDF/XML 中引入主体和客体 URI?

So how do we introduce subject and object URIs in RDF/XML?

  1. rdf:about 设置语句的主题 URI,可以是绝对的 (http://example.com/) 或相对于语句的 BASE 解析文档(例如 /foo/bar#frag).(就像html中的href)
  2. rdf:resource 设置语句的对象 URI,同样是绝对的或相对的.
  3. rdf:ID 设置主题 URI,但它只能在此文档内.一个 ID 也只能使用一次.很像 HTML 中的 id="baz".
  1. rdf:about sets the subject URI of a statement, which may be absolute (http://example.com/) or resolved relative to the BASE of the document (e.g. /foo/bar, #frag). (Like href in html)
  2. rdf:resource sets the object URI of a statement, once again either absolute or relative.
  3. rdf:ID sets the subject URI, but it can only be within this document. An ID can also only be used once. Very like <a name="baz"> or id="baz" in html.

rdf:ID 是不鼓励的,因为

  1. 你可以用 rdf:aboutrdf:resource 替换它和片段 #baz
  2. 如果多次使用相同的 ID,可能会导致 xml 问题.
  1. you can replace it with an rdf:about or rdf:resource with a fragment #baz and
  2. it can cause xml issues if you use the same id more than once.

也就是说,它是多余的并且是潜在的错误来源.

That is, it's redundant and a potential source of errors.

回想起来,通常只需要一个属性来指定一个 URI,因为从 RDF/XML 语法中可以明显看出某事物是主体还是客体:

In retrospect there typically only needs to be one attribute to specify a URI, since whether something is a subject or object is apparent from the RDF/XML syntax:

<ex:Foo ...> - subject
  <ex:prop ... /> - property then object
</ex:Foo>

<ex:Foo ...> - subject
  <ex:prop> - property
    <ex:Bar ... /> - subject (and implictly an object chaining from previous) 
...

(经验法则:奇数行rdf:about,偶数行,rdf:resource)

(rule of thumb: odd lines rdf:about, even lines, rdf:resource)

并且在元素上同时使用 rdf:aboutrdf:resource 几乎总是一个错误(您要么处于主语位置,要么处于宾语位置).

and using both rdf:about and rdf:resource on an element is almost always an error (you're either in a subject position or object position).

避免使用 rdf:ID.使用 rdf:aboutrdf:resource 很像 href,前者用于主体,后者用于对象.

Avoid rdf:ID. Use rdf:about and rdf:resource much like an href, the former for subject, the latter for objects.

忘了提到 rdf:ID 可以用在属性元素上,但它做了一些你可能会发现意想不到的事情:它具体化了三元组.避免 rdf:ID.

Forgot to mention that rdf:ID can be used on a property element, but it does something you may find unexpected: it reifies the triple. Avoid rdf:ID.

这篇关于rdf:resource、rdf:about 和 rdf:ID 之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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