通常,在 XML 中,当将 # 作为短文本字符串的前缀时,用于指示 XML“片段”。它只是告诉浏览器在加载整个页面后使用 @ID 属性跳转到将文本指定为 ID 的 XHTML 元素。
在 RDFa 中,人们似乎倾向于在创建词汇表时使用它,以避免为每个不同的术语创建不同的 URL。假设主 URI 类似于“www.example.com/vocabulary/”,那么词汇表创建者可以选择使词汇表术语的 URI 具有如下 URI:“www.example.com/vocabulary/term1”或者像这样:“www.example.com/vocabulary#term1”。如果这些 URI 仅用作不解析为实际网页的空灵 URI,那么这只是一个没有区别的区别。然而,如果所述创建者打算创建一个网页来描述所述词汇表,那么他们可能更容易使用后者,因为整个词汇表的描述会出现在一个 URL 为“www.example.com/”的网页上。 vocabulary/index.html”并且#term1将导致浏览器跳转到使用@ID属性将term1设置为ID的XHTML元素。
然而,问题是,我还在有关 RDFa 的各种解释和教程中看到哈希标记以不同的方式使用。我已经看到它在 @about 属性中使用,如下所示:
<span about="#jane">
<!-- Other RDFa or XHTML in here. -->
</span>
在这种情况下,这些教程声称 #jane 现在是一个主题 URI,人们可以编写关于它的谓词和对象。但是,如果 #jane 是一个 URI,“她”的完整 URI 是什么?它会是页面当前的基本 URI,并在其末尾附加 #jane 吗?如果是这样,那么 about="#jane" 属性是否提供与同一 XHTML 元素中的 ID="jane" 属性等效的功能?但是,about="#jane" 可以在许多不同的 XHTML 元素中使用,这会给它们提供相同的 ID,这是非法的。
我们是否创建了一个使用 #jane 作为其节点 ID 的空白节点 (bNode),然后开始谈论该空白节点?但是,我认为创建空白节点的正确方法是 about="[_:jane]" 所以我很困惑。
或者我们是否正在讨论同一页面上其他位置的某个包含 ID="jane" 属性的 XHTML 元素,该元素可能已创建,也可能尚未创建,但在示例中根本没有提及?
或者所有这些教程和示例的作者都只是使用教程中普遍接受的速记法,但没有解释他们到底在做什么?如果是这样,我有很多家伙,当我见到他们时,我会打他们的头。
Normally, in XML the #, when prefixed onto a short string of text, is used to indicate an XML "fragment." It merely tells the browser to jump to the XHTML element with that text assigned as the ID using the @ID attribute after the whole page has been loaded.
In RDFa, it seems that people tend to use this when creating vocabularies to avoid the necessity of creating a different URL for each different term. Suppose the primary URI is something like "www.example.com/vocabulary/" then the vocabulary creator has the option of making the URIs for the terms of the vocabulary have URIs like this: "www.example.com/vocabulary/term1" or like this: "www.example.com/vocabulary#term1". If these URIs were only ever going to be used as ethereal URIs that do not resolve to an actual web page then it is a distinction without a difference. However, if said creator intends to create a web page to describe said vocabulary then it may be easier for them to use the latter because then the description of the whole vocabulary appears on one web page with a URL of "www.example.com/vocabulary/index.html" and the #term1 will cause the browser to jump to the XHTML element with term1 set as the ID using the @ID attribute.
However, and here is the question, I have also seen the hash-mark used a different way in various explanations and tutorials about RDFa. I have seen it used within the @about attribute like this:
<span about="#jane">
<!-- Other RDFa or XHTML in here. -->
</span>
In this case, these tutorials claim that #jane is now a subject URI, about which, one could write predicates and objects. But, if #jane is a URI what would be the full URI for "her"? Would it be the current base URI of the page with #jane appended to the end of it? If this is so, then does the about="#jane" attribute provide the equivalent function as an ID="jane" attribute in the same XHTML element? But, about="#jane" could be used in many different XHTML elements which would give them all identical IDs, which is illegal.
Have we created a blank node (bNode) that uses #jane as its node-ID and then started saying things about that blank node? But, I thought the correct way to create a blank node would be about="[_:jane]" so I am confused.
Or are we talking about some XHTML element, containing an ID="jane" attribute, elsewhere on the same page that may or may not have been created but is simply not mentioned in the examples?
Or are all the writers of all these tutorials and examples simply using a shorthand that is commonly accepted within tutorials, but without explaining what the heck they are doing? If so, I have got a lot of dudes that I am gonna smack upside the head when I meet them.
发布评论
评论(1)
在 RDFa 中,about="#xyz" 分配一个相对 URI 作为以下 RDF 语句的主题的标识符。
关于如何从本地标识符派生全局 URI 的正式规范有点复杂,但实际上,它将是资源的基本 URI 加上片段部分。如果未显式设置文档的基本 URI,则这将是从中检索表示的 URI。
因此,如果您有一个文件product.html,并使其在URI
http://www.example.org 下可用/product.html(请注意,本地文件名和公共 URI 不是硬连线的),
然后节点
将为此数据元素分配全局 URI
http://www.example.org/product.html#offer
现在,您需要这个做什么?
最常见的情况是,您可能希望在另一个资源中做出有关此实体的陈述,然后可以使用该陈述来整理巨型图中有关同一对象的所有信息。
但是您也可以使用该技术来整理分散在同一 HTML 文档中的元数据,因为多次使用具有相同标识符的“about”是完全合法的。
例如,您可以使用此行
和下面的 500 行:
RDFa 解析器将知道 gr:name 和 gr:description 属性属于同一对象。
在微数据语法中,您可以使用稍微优雅的“itemref”关键字来直接链接包含引用同一对象的元数据的 HTML 元素。在 RDFa 中,您只能通过重复使用相同的“about”标识符来间接集成分散在 HTML 中的内容。
简而言之:
因此,如果跳转到产品的片段标识符
不要使用 about=#product",而是使用 about="# Product_data”用于标识数据对象。
现在,为什么是片段标识符在示例中如此流行?因为您将轻松获得全局使用该模板的每个单独页面的标识符 - 想象一家有 1,000 件商品在售的商店,如果您添加
产品数据标记元素,则每个产品都将具有其他人可以引用的全局标识符。
到 /strong> 某些模板将所有单独页面的基本 URI 设置为主页,在这种情况下,所有产品都将获得相同的 URI,因此,如果将基本 URI 设置为除规范 URI 之外的任何内容,则相对 URI 不起作用。那个人 页。
In RDFa, about="#xyz" assigns a relative URI as the identifier for the subject of the following RDF statements.
The formal specification of how a global URI is derived from a local identifier are a bit complicated, but practically, it will be the base URI of the resource plus the fragment part. If the base URI of the document is not set explicitly, this will be the URI from which the representation has been retrieved.
So if you have a file product.html and make this available under the URI
http://www.example.org/product.html (note that the local filename and the public URI are not hard-wired),
then a node
will assign this data element the global URI
http://www.example.org/product.html#offer
Now, what do you need this for?
The most popular case is that you may want make statements about this entity in another resource, which can then be used to collate all information about the same object in a giant graph.
But you can also use the technique for collating meta-data scattered around the same HTML document, because you it is perfectly legal to use "about" with the same identifier multiple times.
For instance, you could use this
and 500 lines below:
An RDFa parser will then know that both the gr:name and the gr:description properties belong to the same object.
In microdata syntax, you have the slightly more elegant "itemref" keyword for directly linking the HTML elements that contain meta-data referring to the same object. In RDFa, you can only do indirect integration of content scattered around the HTML via reusing the same identifier for "about".
So in a nutshell:
So if the fragment identifier to jump to the product is
do not use about=#product", but e.g. about="#product_data" for identifying the data object.
Now, why is a fragment identifier so popular in examples? Because you will easily get global identifiers for each individual page using that template - think of a shop with 1,000 items on sale. If you add
to the product data markup element, then each single product will have a global identifier that others can refer to.
Caveat: Some templates set the base URI of all individual pages to the main page. In this case, all products would get the same URI. So relative URIs don't work if you set the base URI to anything but the canonical URI of that individual page.