2011-10-12 32 views
13

Giả sử tôi có trang này HTML đơn giản về một chàng trai nhận được một công việc:Làm cách nào để liên kết các mục trong 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> 

Nếu tôi thêm dữ liệu ngữ nghĩa bằng cách sử dụng từ vựng schema.org, nó có thể trông như thế này:

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

Đầu tiên đoạn văn rõ ràng về con người, John Doe và đoạn thứ hai là về một công ty, Tập đoàn MITER. Nhưng "MITER" trong đoạn đầu tiên cũng giống như "Tập đoàn MITER" trong lần thứ hai. Làm thế nào để khai báo một cách rõ ràng những điều này là một và giống nhau bằng cách sử dụng schema.org?

Trả lời

1

nỗ lực đầu tiên của tôi để trả lời câu hỏi của riêng tôi là để sử dụng thuộc tính itemref, như vậy:

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

Nhưng một số các bình luận một cách đúng đắn chỉ ra đây không phải là quyền sử dụng của thuộc tính này.

Vì vậy, đây là nỗ lực thứ hai của tôi: Sử dụng thuộc tính itemid thay thế. Cả hai trường hợp của tên công ty đều được cung cấp thuộc tính itemscopeitemtype và cả hai đều được đặt thành cùng một giá trị itemid, là một URL.

spec says: "Thuộc tính itemid, nếu được chỉ định, phải có giá trị là URL hợp lệ có khả năng được bao quanh bởi dấu cách ... Mã định danh toàn cục của một mục là giá trị thuộc tính itemid của phần tử, nếu nó có một , được giải quyết liên quan đến phần tử mà thuộc tính được chỉ định ... Thuộc tính itemid không được chỉ định trên các phần tử không có cả thuộc tính itemscope và thuộc tính itemtype được chỉ định. "

<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

Tôi đã thử rằng, [dường như nó thực sự không ảnh hưởng đến mô hình dữ liệu] (http://goo.gl/agxIv). – robertc

+2

itemref chỉ được sử dụng để trỏ đến các thuộc tính bổ sung cho một itemscope. Vì vậy, trong trường hợp này, thẻ đó cũng sẽ cần phải là một loại itemtype. và thẻ có id = "The MitreCorporation" không thể là một itemscope. –

4

// Cập nhật: Schema.org mở rộng thông số kỹ thuật của họ về schema perso

rõ ràng Người có liên quan đến Công ty, vì vậy những gì bạn có thể làm là để tạo ra một mối quan hệ giữa con người và tổ chức wit "người ´s "itemprop" liên kết " vì vậy những gì tôi đã làm là gói các đoạn với itemscope itemtype =" Person "và mở rộng Schema Person bằng cách thêm itemprop" affiliation "và itemscope itemtype =" Organization "để bây giờ có mối quan hệ ngữ nghĩa, người được liên kết với tổ chức. Tôi cũng đã thêm thẻ meta với itemprop = "name" vì Nó rất cần thiết để hoàn thành "Person" thông số kỹ thuật

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

Bạn có thể đặt này vào google giàu công cụ kiểm tra đoạn và tôi đoán ra là gì bạn cần tìm cho

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 
Các vấn đề liên quan