刚刚进入语义世界,有些东西我还看不懂。我试图弄清楚如何根据其上的 Microdata 标签检查哪种元素是 HTML 元素。我在 Firefox 扩展上工作,所以我对请求和低权限的东西没有限制。我只需要弄清楚元素是什么,并通过了解架构中定义的“事物”的种类,以用户可理解的语言(例如,没有 MusicRecording
)显示警报。考虑这个微数据示例:
<div itemscope itemtype="http://schema.org/MusicRecording">
<span itemprop="byArtist" itemscope itemtype="http://schema.org/MusicGroup">
British rock band
<span itemprop="name">Queen</span>
</span>
for their
<span itemprop="inAlbum" itemscope itemtype="http://schema.org/MusicAlbum">
<span itemprop="dateCreated">1977</span> album
<span itemprop="name">News of the World</span>
</span>
<div>
通过读取项目类型,我需要能够检索事物的名称(类似于“音乐录音”),但不能分析字符串;以“正确的方式”,通过查询和要求。问题是,我找不到用于获取名称的 REST api 或类似的东西,我需要使用纯 javascript 来完成。
那么……有什么线索/想法吗? (除了询问此类 URL 的 DOM)
最佳答案
canonical machine-readable representation Schema.org 词汇表的一部分在 RDFa 中: http://schema.org/docs/schema_org_rdfa.html
在此文件中,每个 Schema.org 类型 (rdfs:Class
) 都有一个 rdfs:label
property 的值,“可用于提供资源名称的人类可读版本”。
但是,Schema.org 团队似乎决定提供 URL 中给出的标签,因此对于 http://schema.org/MusicRecording
,它是“MusicRecording”,而不是“音乐录音”:
<div typeof="rdfs:Class" resource="http://schema.org/MusicRecording"> <span class="h" property="rdfs:label">MusicRecording</span> <span property="rdfs:comment">A music recording (track), usually a single song.</span> <span>Subclass of: <a property="rdfs:subClassOf" href="http://schema.org/CreativeWork">CreativeWork</a></span> </div>
关于javascript - 使用来自 getschema.org IOT 的 JSON 数据获取 "thing"名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34886989/