尝试在语义上标记有关特定地址的报告页面。该页面提供有关地址能耗的报告,并提供与能耗相关的服务。我想在语义上代表地点的地址,与地址相关的能源报告以及地址可用的优惠。现在,我有一个标记,它有一个RDFa lite节点用于地方,另一个节点用于商品。建立这些事物之间关系的最佳方法是什么,例如能源报告和这个地方的相关报价?
<!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>
答案 0 :(得分:4)
<div vocab="http://schema.org/" typeof="Place" additionaltype="Offer" resource="#energyreport">
首先,additionaltype
属性在HTML中无效,不应使用。使用RDFa,您可以安全地在typeof
属性中添加多种类型,如下所示:typeof="Place Offer"
。
为了补充约书亚所说的(这很棒),如果你不想添加一个可见的链接,你也可以使用一个不可见的<link>
元素:
<link property="offer" href="#offer" />
检查您的RDFa的另一个是RDFa / Play。 RDFa.info's Tools可以使用更多工具。
答案 1 :(得分:3)
如果您还没有,我建议您试用W3C's RDFa 1.1 Distiller and Parser。您可以复制RDFa并查看生成的数据。例如,您当前的标记产生了这些三元组:
@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 .
这意味着您有一个相对容易使用的工具,用于检查对您的标记的修改是否会产生您正在寻找的各种结果。 (您还应该检查上面的三元组是否准确地代表了您迄今为止尝试表示的数据。)我认为现在数据可能存在一些问题。例如,您是否真的打算报告是一个地方,即:
#energyreport a schema:Place
无论如何,要添加一件事与另一件事之间的关系,只需添加另一个链接,就像你迄今为止所做的那样,但是使用另一个资源的标识符。例如,如果添加
<a href="#offer" rel="hasOffer">an offer for this place</a>
到描述div
的{{1}},以便您拥有:
你会得到三倍像:
#energyreport
包括您想要的关系(以所使用的特定URI为模):
<#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""" .