2011-10-12 12 views
13

Supponiamo che io sono questo semplice pagina HTML di un ragazzo ottenere un lavoro:Come posso correlare gli articoli in 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> 

Se aggiungo dati semantici utilizzando il vocabolario schema.org, potrebbe assomigliare a questo:

<!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> 

La prima il paragrafo riguarda ovviamente la persona, John Doe, e il secondo paragrafo riguarda un'azienda, la MITRE Corporation. Ma il "MITRE" nel primo paragrafo è lo stesso di "The MITER Corporation" nel secondo. Come faccio a dichiarare esplicitamente che si tratta della stessa cosa usando schema.org?

risposta

1

Il mio primo tentativo di rispondere alla mia domanda era quello di utilizzare l'attributo itemref, in questo modo:

<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> 

Ma alcuni dei commentatori ha giustamente sottolineato che questo non era il giusto uso di questo attributo.

Quindi, ecco il mio secondo tentativo: utilizzare invece l'attributo itemid. Entrambe le istanze del nome della società hanno un attributo itemscope e itemtype e sono entrambe impostate sullo stesso valore itemid, che è un URL.

spec says "L'attributo itemid, se specificato, deve avere un valore che è un URL valido potenzialmente circondato da spazi ... L'identificatore globale di un elemento è il valore dell'attributo itemid dell'elemento, se ne ha uno risolti relativi all'elemento su cui è specificato l'attributo ... L'attributo itemid non deve essere specificato su elementi che non hanno sia un attributo itemscope sia un attributo itemtype specificato. "

<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

Ho provato quello, [non sembrava che effettivamente influenzato il modello di dati] (http://goo.gl/agxIv). – robertc

+2

itemref viene utilizzato solo per puntare a proprietà aggiuntive per un ItemCope. Quindi in questo caso quel tag dovrebbe anche essere un itemtype della corporation. e il tag con id = "The MitreCorporation" non può essere un itemcope. –

4

// Update: Schema.org ampliato le loro specifiche di schema perso

ovviamente la persona sia legata alla Società, in modo da che cosa si può fare è quello di fare una relazione tra persona e organizzazione ingegno "persona "Itemprop" affiliazione " quindi quello che ho fatto è avvolgere i paragrafi con itemscope itemtype =" Person "e ampliato lo Schema Person aggiungendo itemprop" affiliazione "e itemscope itemtype =" Organizzazione "così ora c'è una relazione semantica, la persona è affiliato con l'organizzazione. Ho anche aggiunto meta tag con itemprop = "nome" perché's necessari per adempiere "persona" specifiche

<!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> 

Si può mettere questo in ricco strumento di test snippet di Google e credo che l'uscita è ciò che stavi cercando per

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 
Problemi correlati