2013-10-15 46 views
2

試圖在語義上標記關於特定地址的報告頁面。該頁面提供有關該地址能耗的報告,並提供與能耗相關的服務報價。我想在語義上表示地址的地址,與地址相關的能源報告以及地址可用的報價。現在,我的標記有一個RDFa lite節點用於放置,另一個節點用於優惠。建立這些事情之間關係的最佳方式是什麼?例如能源報告和這個地方的相關報價?如何建立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> 

回答

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> 

來描述#energyreportdiv,使您有:

能源評估 1 MAIN ST。 townville, ca 1主要街道,townville,ca.的能源潛力。探索安裝優惠。爲您的家尋找最佳選擇。 這個地方

的報價,你會得到這樣的三元組:

<#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的使用):

<#energyreport> schema:hasOffer <#offer> 
+0

謝謝你,有道理。你認爲在任何詞彙表中都不存在頂級模式類型存在任何問題。所以如果報告是有報價並有地址的報告,報告是不是真的在任何地方定義的東西,或者它會讓我能夠定義這些東西。我認爲創造頂級水平的原因是,報告將是一個地方的語義表示,其中包含能源報告並提供相關報價。 –

+0

@SeanParker如果你可以找到一個已經有你需要的屬性的詞彙,那麼最好使用這些屬性,但是也可以定義你自己的屬性和類。儘管如此,你應該使用絕對IRI,這樣你就可以得到像雖然。 –

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獲得。

相關問題