2011-10-12 20 views
13

Załóżmy, że mam tę prostą stronę HTML o facecie znalezienie pracy:Jak powiązać elementy w schema.org?

<!DOCTYPE HTML> 
<html> 
    <head> 
     <meta charset="utf-8"> 
     <title>New Job for John Doe</title> 
    </head> 
    <body> 
     <h1>New Job for John Doe</h1> 
     <p>This week John Doe accepted an offer to become a Software Engineer at MITRE. John graduated from MIT in 2005 with a BS in Computer Science. He previously worked at a small company near Boston. Blah, blah, blah.</p> 
     <p>The MITRE Corporation is a not-for-profit organization chartered to work in the public interest. The MITRE Corporation has two principal locations: Bedford, Massachusetts, and McLean, Virginia. Blah, blah, blah.</p> 
    </body> 
</html> 

Jeśli dodać dane semantyczne używając słownictwa schema.org, może to wyglądać tak:

<!DOCTYPE HTML> 
<html> 
    <head> 
     <meta charset="utf-8"> 
     <title>New Job for John Doe</title> 
    </head> 
    <body> 
     <h1>New Job for John Doe</h1> 
     <p itemscope itemtype="http://schema.org/Person">This week John Doe accepted an offer to become a <span itemprop="jobTitle">Software Engineer</span> at <span itemprop="worksFor">MITRE</span>. John graduated from <span itemprop="alumniOf">MIT</span> in 2005 with a BS in Computer Science. He previously worked at a small company near Boston. Blah, blah, blah.</p> 
     <p itemscope itemtype="http://schema.org/Corporation">The MITRE Corporation is a not-for-profit organization chartered to work in the public interest. The MITRE Corporation has two principal locations: <span itemprop="location">Bedford, Massachusetts</span>, and <span itemprop="location">McLean, Virginia</span>. Blah, blah, blah.</p> 
    </body> 
</html> 

Pierwszy akapit dotyczy oczywiście osoby, John Doe, a drugi akapit dotyczy firmy, The MITER Corporation. Ale "MITER" w pierwszym akapicie jest taki sam jak "Korporacja MITER" w drugim. W jaki sposób jawnie deklaruję, że są one takie same za pomocą schema.org?

Odpowiedz

1

Moja pierwsza próba odpowiedzi na moje własne pytanie było użyć atrybutu itemref, tak:

<p itemscope itemtype="http://schema.org/Person"> 
    This week John Doe accepted an offer to become a 
    <span itemprop="jobTitle">Software Engineer</span> 
    at <span itemprop="worksFor" itemref="TheMitreCorporation">MITRE</span>. 
    John graduated from <span itemprop="alumniOf">MIT</span> 
    in 2005 with a BS in Computer Science. 
    He previously worked at a small company near Boston. Blah, blah, blah. 
</p> 

<p itemscope itemtype="http://schema.org/Corporation" id="TheMitreCorporation"> 
    The MITRE Corporation is a not-for-profit organization chartered to work in the public interest. 
    The MITRE Corporation has two principal locations: 
    <span itemprop="location" itemscope itemtype="http://schema.org/Place"> 
     <span itemprop="name">Bedford, Massachusetts</span> 
    </span>, and 
    <span itemprop="location" itemscope itemtype="http://schema.org/Place"> 
     <span itemprop="name">McLean, Virginia</span> 
    </span>. Blah, blah, blah. 
</p> 

Ale niektórzy z komentujących słusznie zauważył to nie było właściwe stosowanie tego atrybutu.

Oto moja druga próba: użyj zamiast tego atrybutu itemid. Obie instancje nazwy firmy otrzymują atrybut itemscope i itemtype i oba mają tę samą wartość itemid, która jest adresem URL.

spec says: "Atrybut itemid, o ile został określony, musi mieć wartość, która jest prawidłowym adresem URL potencjalnie otoczonym spacjami ... Globalnym identyfikatorem elementu jest wartość atrybutu itemid jego elementu, jeśli ma on jeden z atrybutów itemid. , rozstrzygnięty w odniesieniu do elementu, dla którego określony jest atrybut ... Atrybut itemid nie może być określony w elementach, które nie mają zarówno atrybutu itemscope, jak i określonego atrybutu itemtype. "

<p itemscope itemtype="http://schema.org/Person">This week John Doe accepted an offer to become a <span itemprop="jobTitle">Software Engineer</span> at <span itemprop="worksFor" itemscope itemtype="http://schema.org/Corporation" itemid="http://www.mitre.org">MITRE</span>. John graduated from <span itemprop="alumniOf">MIT</span> in 2005 with a BS in Computer Science. He previously worked at a small company near Boston. Blah, blah, blah.</p> 
<p itemscope itemtype="http://schema.org/Corporation" itemid="http://www.mitre.org">The MITRE Corporation is a not-for-profit organization chartered to work in the public interest. The MITRE Corporation has two principal locations: <span itemprop="location" itemscope itemtype="http://schema.org/Place"><span itemprop="name">Bedford, Massachusetts</span></span>, and <span itemprop="location" itemscope itemtype="http://schema.org/Place"><span itemprop="name">McLean, Virginia</span></span>. Blah, blah, blah.</p> 
+0

Próbowałem tego, [nie wyglądało na to, że wpłynęło to faktycznie na model danych] (http://goo.gl/agxIv). – robertc

+2

itemref służy tylko do wskazania dodatkowych właściwości dla paska przedmiotów. W takim przypadku tag ten musiałby być również typem korporacyjnym. a tag z id = "The MitreCorporation" nie może być itemcope. –

4

// Aktualizacja: Schema.org rozszerzyli swoje specyfikacje PERSO schematu

oczywiście osoba jest związana ze Spółką, więc co można zrobić, to zrobić relację między człowiekiem i organizacji dowcipu „osoba "Itemprop" przynależność " więc to, co zrobiłem, jest owijanie akapitów itemscope itemtype =" Person "i rozszerzyłem Schema Person, dodając itemprop" powiązanie "i itemscope itemtype =" Organization ", więc teraz istnieje związek semantyczny, osoba jest powiązany z organizacją. Dodałem też tag meta z itemprop = „name”, ponieważ its potrzebne do spełnienia „osoba” specyfikacji

<!DOCTYPE HTML> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title>New Job for John Doe</title> 
</head> 
<body> 
<div itemscope itemtype="http://schema.org/Person"> 
    <h1>New Job for John Doe</h1> 
<meta itemprop="name" content="John Doe" /> 
    <p>This week John Doe accepted an offer to become a <span itemprop="jobTitle">Software Engineer</span> at <span itemprop="worksFor">MITRE</span>. John graduated from <span itemprop="alumniOf">MIT</span> in 2005 with a BS in Computer Science. He previously worked at a small company near Boston. Blah, blah, blah.</p> 
    <p itemprop="affiliation" itemscope itemtype="http://schema.org/Organization">The MITRE Corporation is a not-for-profit organization chartered to work in the public interest. The MITRE Corporation has two principal locations: <span itemprop="location">Bedford, Massachusetts</span>, and <span itemprop="location">McLean, Virginia</span>. Blah, blah, blah.</p> 
</div> <!-- closing Schema "Person" --> 
</body> 
</html> 

Można umieścić to w google fragment bogatej narzędzie do testowania i myślę, wyjście jest to, czego szuka, gdzie for

Item 
type: http://schema.org/person 
property: 
name: John Doe 
jobtitle: Software Engineer 
worksfor: MITRE 
alumniof: MIT 
affiliation: Item 1 


Item 1 
type: http://schema.org/organization 
property: 
location: Bedford, Massachusetts 
location: McLean, Virginia 
Powiązane problemy