三种Web语义化框架的比较
来源:互联网 发布:阮一峰javascript pdf 编辑:程序博客网 时间:2024/05/17 08:34
将要描述的三种We语义化技术分别是RDFa、Microformat和Microdata,除了RDFa比较繁锁,而且主要是为XML文档服务,Microformat和Microdata都更适合HTML。Microformat和Microdata各有优缺点。Microformat在于重用现在的属性和元素,而microdata则是通过在元素上添加4个属性来完成了。
资源描述框架-in-attributes
Resource Description Framework – in –attributes(RDFa)是W3C推荐用来在HTML,XHTML或其它基于XML的文档中嵌入元数据的一种框架。只不过,所有这些元数据全都是通过attribute的方式实现的。
The essence ofRDFa is to provide a set of attributes that can be used to carry metadata in anXML language (hence the 'a' in RDFa).
有一个术语先要学习一下:搭配资源(Partnersource,the resource that the metadata is about)。
- about – 用于指定搭配资源的URI或CURIE。
- rel and rev – 分别指与另一个资源的正关系和反关系。
- src, href and resource – 指定搭配资源
- property – 为元素或搭配资源的内容指定一个属性
- content – 当property存在的时候,content用于覆盖元素的原来内容。
- datatype – 当property存在的时候,指明text的datatype。
- typeof – 搭配资源的RDFa类型.
举例 – XHTML + RDFa 1.0:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="XHTML+RDFa 1.0" xml:lang="en"> <head> <title>John's Home Page</title> <base href="http://example.org/john-d/" /> <meta property="dc:creator" content="Jonathan Doe" /> <link rel="foaf:primaryTopic" href="http://example.org/john-d/#me" /> </head> <body about="http://example.org/john-d/#me"> <h1>John's Home Page</h1> <p>My name is <span property="foaf:nick">John D</span> and I like <a href="http://www.neubauten.org/" rel="foaf:interest" xml:lang="de">Einstürzende Neubauten</a>. </p> <p> My <span rel="foaf:interest" resource="urn:ISBN:0752820907">favorite book is the inspiring <span about="urn:ISBN:0752820907"><cite property="dc:title">Weaving the Web</cite> by <span property="dc:creator">Tim Berners-Lee</span></span> </span> </p> </body></html>
举例 – HTML5 + RDFa 1.1
<html prefix="dc: http://purl.org/dc/elements/1.1/" lang="en"> <head> <title>John's Home Page</title> <link rel="profile" href="http://www.w3.org/1999/xhtml/vocab" /> <base href="http://example.org/john-d/" /> <meta property="dc:creator" content="Jonathan Doe" /> <link rel="foaf:primaryTopic" href="http://example.org/john-d/#me" /> </head> <body about="http://example.org/john-d/#me"> <h1>John's Home Page</h1> <p>My name is <span property="foaf:nick">John D</span> and I like <a href="http://www.neubauten.org/" rel="foaf:interest" lang="de">Einstürzende Neubauten</a>. </p> <p> My <span rel="foaf:interest" resource="urn:ISBN:0752820907">favorite book is the inspiring <span about="urn:ISBN:0752820907"><cite property="dc:title">Weaving the Web</cite> by <span property="dc:creator">Tim Berners-Lee</span></span> </span> </p> </body></html>
你也许已经发现foaf前缀没有用声明,其实RDFa 1.1自动会把一些流行的词汇前缀自动加入。http://www.w3.org/2011/rdfa-context/rdfa-1.1
Microformat
Microformat通过重用现有的HTML/XHTML标签或web页面的某些属性来传送(convey)元数据。
从技术层面来说,microformat主要使用下面几个属性来指示元数据的存在:
l class: classname
l rel: a锚元素目的地址的描述
l rev: 引用文档的反关系
举例 – classname
The birds roosted at <span class="geo"> <span class="latitude">52.48</span>, <span class="longitude">-1.89</span> </span>
应用
网络爬虫(web crawlers)可以从microsformat收集更多关于网络资源的数据,邮件或行程安排等软件可以从microformat获取更多详细信息。
已经有几个扩展(extensions),Operator为firefox,Oomph为IE,提供了检测microformat的能力。雅虎的Query Language可以从网络页面中抽取microformat。Google,2009年5月声明,他们将把页面中抽取到的hCard, hReview, hProduct等microformat也放在搜索结果页面。Bing和Yahoo!也正在实现获取microformat。
Microdata(HTML)
Microdata是专门为HTML提供的,搜索引擎、网络爬虫和浏览器都可以从页面中抽取和处理microdata。这个方式比RDFa和Microformats都要简单,而且机器可读。
Microdata全局属性
l itemscope – 创建item,并暗示元素的子节点有关于这个item的信息;
l itemtype – 描述item和它的属性上下文的一个有效的词汇URL;
l itemprop – 指示包含该属性的标签包含item某个属性的值;这个值一般是字符串,也可能是URL,比如img的src或a元素的href属性;
l itemref – 表明还有一些属性不在有itemscope标明的子元素里,而是在文档的其它地方,itemref的值是元素的id,可以是多个id。
举例
<section itemscope itemtype="http://schema.org/Person"> Hello, my name is <span itemprop="name">John Doe</span>, I am a <span itemprop="jobTitle">graduate research assistant</span> at the <span itemprop="affiliation">University of Dreams</span>. My friends call me <span itemprop="additionalName">Johnny</span>. You can visit my homepage at <a href="http://www.JohnnyD.com" itemprop="url">www.JohnnyD.com</a>. <section itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"> I live at <span itemprop="streetAddress">1234 Peach Drive</span>, <span itemprop="addressLocality">Warner Robins</span>, <span itemprop="addressRegion">Georgia</span>. </section></section>
支持
l Google可以在搜索结果页面使用microdata。
l 几个著名的浏览器已经提供了microdata的DOM API:
浏览器
版本
是否支持
Maxthon
3.3.9.600
Yes
Opera
11.60
Yes
Firefox
16.0a1
Yes
Chrome
No
Internet Explorer
No
Safari
No
l 用来操作microdata的JS库包括: MicrodataJS,jQuery,其中jQuery模拟了DOM API。
- 三种Web语义化框架的比较
- Web语义化的理解
- web语义化的理解
- 企业应用集成中语义Web服务框架的研究
- web开发框架的比较
- 关于web语义化的一些感悟
- 语义Web的概念
- storm 的三种计算语义
- J2ee三种框架 比较
- 语义web服务描述语言比较
- 理解web语义化
- 关于Web语义化
- web标签语义化
- Web语义化
- Web语义化
- WEB语义化
- web语义化
- Web语义化
- GCC指令详解
- 使用servlet,jsp网页编码错误
- SDFormatter(手机内存卡格式化修复工具) v4.0 中文免费版
- linux shell正则表达式
- iPhone4S iOS6.1.2完美越狱
- 三种Web语义化框架的比较
- 写的jquery分页插件AmSetPager
- 关于YII生成表单
- JavaScript DOM编程艺术-语法/DOM
- 操作系统概论——处理器管理
- 推荐无监督特征学习和深度学习的在线教程,Andrew Ng
- 从oracle中读取数据并保存在txt文件中
- C开发注意事项_字符串及指针使用
- javascript事件模型与事件监听器【知识总结】