2014-02-19 15 views
-1

我想知道微数据是否支持键入列表。我试图做到以下几点:Microdata数组的项目类型

<div itemscope itemtype="http://example/Person"> 
    <span itemprop="name">Charlie</span>  
    <span itemprop="address">...</span> 
    <ul itemprop="Friends"> 
     <li itemscope itemtype="http://example/Person"> 
      <span itemprop="name">Dennis</span> 
      <span itemprop="address">...</span> 
     </li> 
     <li itemscope itemtype="http://example/Person"> 
      <span itemprop="name">Mac</span> 
      <span itemprop="address">...</span> 
     </li> 
    </ul> 
</div> 

但它可以解析为:

{ 
    "items": [ 
     { 
      "type": [ 
      "http://example/Person" 
      ], 
      "properties": { 
      "name": [ 
       "Charlie" 
      ], 
      "address": [ 
       "..." 
      ], 
      "Friends": [ 
       "\n\t\t\n\t\t\tDennis\n\t\t\t...\n\t\t\n\t\t\n\t\t\tMac\n\t\t\t...\n\t\t\n\t" 
      ] 
      } 
     }, 
     { 
      "type": [ 
      "http://example/Person" 
      ], 
      "properties": { 
      "name": [ 
       "Dennis" 
      ], 
      "address": [ 
       "..." 
      ] 
      } 
     }, 
     { 
      "type": [ 
      "http://example/Person" 
      ], 
      "properties": { 
      "name": [ 
       "Mac" 
      ], 
      "address": [ 
       "..." 
      ] 
      } 
     } 
    ] 
} 

当我想到托“朋友”有“人”对象的数组。

回答

1

我不知道如果我得到“数组”或“打字清单”,但也许你可以specify the property on each item? (FWIW,这是Schema.org是怎么做的一般。)

<div itemscope itemtype="http://example/Person"> 
    <ul> <!-- using "friend" instead of "Friends" --> 
     <li itemprop="friend" itemscope itemtype="http://example/Person"></li> 
     <li itemprop="friend" itemscope itemtype="http://example/Person"></li> 
    </ul> 
</div> 

如果有一个“朋友列表”,可能是有序的,也许你可以使用一个特殊的列表项? (FWIW,Schema.org有ItemList。)

<div itemscope itemtype="http://example/Person"> 
    <ul itemprop="hasFriendList" itemscope itemtype="http://example/FriendList"> 
     <li itemprop="friend" itemscope itemtype="http://example/Person"></li> 
     <li itemprop="friend" itemscope itemtype="http://example/Person"></li> 
    </ul> 
</div>