javascript - 使用来自 getschema.org IOT 的 JSON 数据获取 "thing"名称

标签 javascript firefox-addon semantic-web microdata

刚刚进入语义世界,有些东西我还看不懂。我试图弄清楚如何根据其上的 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/

相关文章:

java - 耶拿自定义数据类型

javascript - Twitter 新移动网络体验背后的技术

javascript - 如何使用 JavaScript 检测是否已安装 Internet Explorer 插件

javascript - 改变mozilla插件工具提示框的样式

firefox - 如何在 Firefox 插件的工具栏按钮上显示文本?

rdf - 对于您的语义 Web 类型应用程序,您是否使用 RDF 或专有模型进行内部表示?

javascript - 如何将动态添加的输入字段关联到父元素/id?

javascript - 映射类型 : set key as an object

javascript - jQuery 点击事件似乎有点晚了

SPARQL 查询以获取定义了命名空间前缀的所有类标签