避免hCard中重复数据
我正在修改工作单位的员工目录,将 hCard
数据添加到每个员工的列表中。
我一直无法弄清楚的一个问题是如何避免重复信息,例如组织名称和组织单位。
这是我的代码的精简示例:
<div id="hcard-business" class="vcard">
<div class="adr">
<div class="org fn"><a class="url" href="http://www.business.com/">Business</a></div>
<div class="street-address">123 Business Street</div>
<div>
<span class="locality">City</span>,
<abbr class="region" title="State">ST</abbr>,
<span class="postal-code">99999</span>,
<span class="country-name">USA</span></div>
</div>
</div>
</div>
<table class="contact">
<thead>
<tr><th colspan="4">Marketing Department</th></tr>
<tr class="head"><th>NAME</th><th>TITLE</th><th>PHONE</th><th>EMAIL</th></tr>
</thead>
<tbody>
<tr id="hcard-employee1" class="vcard odd">
<td class="fn">Employee Name</td>
<td class="title">Director</td>
<td class="tel">907-335-1243</td>
<td>
<a class="email" href="mailto:[email protected]">[email protected]</a>
<span class="org fn hidden">
<span class="organization-name">Business Name</span>,
<span class="organization-unit">Marketing</span>
</span>
</td>
</tr>
<tr id="hcard-employee2" class="vcard even">
<td class="fn">Employee Name</td>
<td class="title">Assistant</td>
<td class="tel">907-335-1243</td>
<td>
<a class="email" href="mailto:[email protected]">[email protected]</a>
<span class="org fn hidden">
<span class="organization-name">Business Name</span>,
<span class="organization-unit">Marketing</span>
</span>
</td>
</tr>
</tbody>
</table>
我试图做的是删除最后一个 中的
hidden
范围,抓取 organization -name
来自企业的 hCard
,organization-unit
来自 。
我几乎搜索了 microformats.org 寻找我正在尝试的示例,但没有运气。我什至偷看了他们的几个“野外微格式”列表,但我发现那里有多个员工列表的少数网站使用了相同的隐藏
方法,其中包含我在其中使用的重复信息我的例子。
我正在尝试做的事情可能吗?
I'm revamping my work's Employee Directory, adding hCard
data to each employee's listing.
An issue I haven't been able to figure out is how to avoid duplicating information, such as organization-name
and organization-unit
.
Here's a trimmed-down example of my code:
<div id="hcard-business" class="vcard">
<div class="adr">
<div class="org fn"><a class="url" href="http://www.business.com/">Business</a></div>
<div class="street-address">123 Business Street</div>
<div>
<span class="locality">City</span>,
<abbr class="region" title="State">ST</abbr>,
<span class="postal-code">99999</span>,
<span class="country-name">USA</span></div>
</div>
</div>
</div>
<table class="contact">
<thead>
<tr><th colspan="4">Marketing Department</th></tr>
<tr class="head"><th>NAME</th><th>TITLE</th><th>PHONE</th><th>EMAIL</th></tr>
</thead>
<tbody>
<tr id="hcard-employee1" class="vcard odd">
<td class="fn">Employee Name</td>
<td class="title">Director</td>
<td class="tel">907-335-1243</td>
<td>
<a class="email" href="mailto:[email protected]">[email protected]</a>
<span class="org fn hidden">
<span class="organization-name">Business Name</span>,
<span class="organization-unit">Marketing</span>
</span>
</td>
</tr>
<tr id="hcard-employee2" class="vcard even">
<td class="fn">Employee Name</td>
<td class="title">Assistant</td>
<td class="tel">907-335-1243</td>
<td>
<a class="email" href="mailto:[email protected]">[email protected]</a>
<span class="org fn hidden">
<span class="organization-name">Business Name</span>,
<span class="organization-unit">Marketing</span>
</span>
</td>
</tr>
</tbody>
</table>
What I'm attempting to do is trim out the hidden
span from the last <td>
, grabbing organization-name
from the business' hCard
and organization-unit
from the <thead>
.
I've pretty much scoured microformats.org looking for an example of what I'm attempting, but no luck. I've even peeked at several of their "microformats in the wild" list, but the few sites I found there with multiple employee lists were using the same hidden
method with duplicate information that I've used in my example.
Is what I'm attempting to do even possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从语义的角度来看,试图避免重复是不正确的。尽可能详细(即使以重复代码的名义)是尽可能明确的最有效方法。最好的选择是在执行操作时将其隐藏。根据 hCard 规范,无法引用文档中其他地方的信息。
希望这能解决问题。
From a semantic standpoint, it is incorrect to try to avoid duplication. Being as verbose as possible (even in the name of duplicating code) is the most effective way to be as explicit as possible. Your best option is to hide it as you're doing. There is no way--according to the hCard spec--to reference information elsewhere in the document.
Hope this clears things up.
我认为你应该把事情分开。您公司一张卡,每位员工一张卡。
在每张员工卡上重复组织名称、组织单位根本不是问题。
I think you should separate things. One card for your company, and one card for each employee.
Repeating organization-name, organization-unit on each employee card is not a problem at all.
您可以使用微格式包含模式:
http://microformats.org/wiki/include-pattern
您所要做的就是使用锚点引用父 vcard,例如:
我没有找到任何有关 Google 支持包含模式的信息,但 google 正在解析我的页面,而没有任何警告 http://www.google.com/webmasters/tools/richsnippets 并且我的页面在索引中看起来没问题。
You can use the microformat include pattern:
http://microformats.org/wiki/include-pattern
All you have to do is to reference the parent vcard using a anchor, like:
I did not found any information about Google supporting the include pattern, but google is parsing my pages without any warnings at http://www.google.com/webmasters/tools/richsnippets and my page seems ok in the index.