首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在rdfa lite节点之间建立关系

如何在rdfa lite节点之间建立关系
EN

Stack Overflow用户
提问于 2013-10-16 00:32:07
回答 2查看 511关注 0票数 2

尝试从语义上标记有关特定地址的报告页。该页面提供有关地址能源消耗的报告,并提供与能源消耗相关的服务的报价。我想在语义上表示地址,与地址相关的能源报告,以及地址可用的报价。现在,我有一个标记,它有一个RDFa lite节点用于place,另一个节点用于offers。建立这些事物之间的关系的最佳方式是什么,例如,能源报告和这个地方的相关报价?

代码语言:javascript
复制
<!DOCTYPE html>
<html version="HTML+RDFa 1.1" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Energy Report For 1 main st, townville, ca</title>
</head>
<body>
<div xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:gr="http://purl.org/goodrelations/v1#"
xmlns:pto="http://www.productontology.org/id/"
xmlns:foo="http://example.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#">

<div vocab="http://schema.org/" typeof="Place" additionaltype="Offer"    resource="#energyreport">

<h1 property="name">Energy Assessment for <div property="address" resource="#address" typeof="PostalAddress">
<span property="streetAddress">1 main st.
</span> <span property="addressLocality">townville</span>,
<span property="addressRegion">ca</span></div></h1>
<span property="description">Energy Potential for 1 main st., townville, ca. Explore installation offers. Find the best choice for your home.
</span>
</div>
<div vocab="http://schema.org/" resource="#offer" typeof="Offer">
<!-- The offer to sell it -->   
<div about="#offer" >
<div property="name">Energy Offerings</div>
<div rel="gr:hasBusinessFunction" resource="http://purl.org/goodrelations/v1#Sell"></div>
<div rel="gr:includes">
<!-- The object --> 
<div about="#myObject" typeof="http://www.productontology.org/id/Energy">
<div rel="rdf:type" resource="http://purl.org/goodrelations/v1#SomeItems"></div>
<div property="gr:description" xml:lang="en">Offer Details For Premium Lease Option</div>
<div property="gr:name" xml:lang="en">Premium Lease</div>
</div>
</div>
<div rel="foaf:page" resource="http://URI_of_the_page_containing_the_offer"></div>
<div rel="gr:hasPriceSpecification">
<div typeof="gr:UnitPriceSpecification">
<span property="gr:hasCurrency" content="USD" datatype="xsd:string">$</span>
<span property="gr:hasCurrencyValue" datatype="xsd:float">2.5</span>     
</div>
</div>    
</div>
</div>
</div>
</body>
EN

回答 2

Stack Overflow用户

发布于 2013-10-16 03:10:39

代码语言:javascript
复制
<div vocab="http://schema.org/" typeof="Place" additionaltype="Offer"    resource="#energyreport">

首先,additionaltype属性在超文本标记语言中是无效的,不应该使用。使用RDFa,您可以在typeof属性中安全地放置多个类型,例如:typeof="Place Offer"

为了补充Joshua所说的(这很棒),如果你不想添加一个可见的链接,你也可以使用一个不可见的<link>元素:

代码语言:javascript
复制
<link property="offer" href="#offer" />

另一个检查RDFa的方法是RDFa / PlayRDFa.info's Tools提供了更多工具。

票数 4
EN

Stack Overflow用户

发布于 2013-10-16 02:09:49

如果你还没有准备好,我建议你试试W3C's RDFa 1.1 Distiller and Parser。您可以复制RDFa并查看生成的数据。例如,您当前的标记产生以下三元组:

代码语言:javascript
复制
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix gr: <http://purl.org/goodrelations/v1#> .
@prefix pto: <http://www.productontology.org/id/> .
@prefix rdfa: <http://www.w3.org/ns/rdfa#> .
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<> rdfa:usesVocabulary schema: .

<#energyreport> a schema:Place;
    schema:address <#address>;
    schema:description """Energy Potential for 1 main st., townville, ca. Explore installation offers. Find the best choice for your home.
""";
    schema:name """Energy Assessment for 
1 main st.
 townville,
ca""" .

<#offer> a schema:Offer;
    gr:hasBusinessFunction gr:Sell;
    gr:hasPriceSpecification [ a gr:UnitPriceSpecification;
            gr:hasCurrency "USD"^^xsd:string;
            gr:hasCurrencyValue "2.5"^^xsd:float ];
    gr:includes <#myObject>;
    schema:name "Energy Offerings";
    foaf:page <http://URI_of_the_page_containing_the_offer> .

<#address> a schema:PostalAddress;
    schema:addressLocality "townville";
    schema:addressRegion "ca";
    schema:streetAddress """1 main st.
""" .

<#myObject> a gr:SomeItems,
        pto:Energy;
    gr:description "Offer Details For Premium Lease Option"@en;
    gr:name "Premium Lease"@en .

这意味着您有一个相对容易使用的工具,用于检查对标记的修改是否会产生您想要的结果。(您还应该检查上面的三元组是否准确地表示了到目前为止您试图表示的数据。)我认为现在的数据可能存在一些问题。例如,您是否真的打算将报告放在一个地方,即:

代码语言:javascript
复制
#energyreport a schema:Place 

无论如何,要在一件事和另一件事之间添加关系,只需添加另一个链接,就像您到目前为止所做的那样,但使用另一个资源的标识符。例如,如果您添加了

代码语言:javascript
复制
<a href="#offer" rel="hasOffer">an offer for this place</a>

添加到描述#energyreportdiv中,这样您就可以:

代码语言:javascript
复制
Energy Assessment for      1 main st.      townville,     ca     Energy Potential for 1 main st., townville, ca. Explore installation offers. Find the best choice for your home.          an offer for this place       

你会得到三倍数,如下所示:

代码语言:javascript
复制
<#energyreport> a schema:Place;
    schema:address <#address>;
    schema:description """Energy Potential for 1 main st., townville, ca. Explore installation offers. Find the best choice for your home.
""";
    schema:hasOffer <#offer>;
    schema:name """Energy Assessment for 
1 main st.
 townville,
ca""" .

其中包括您想要的关系(对使用的特定URI取模):

代码语言:javascript
复制
<#energyreport> schema:hasOffer <#offer>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19386362

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档