XML 编程思想:定义 RDF 和 DAML+OIL 图示

姑娘你节操掉咧

姑娘你节操掉咧

2016-02-19 16:52

下面,图老师小编带您去了解一下XML 编程思想:定义 RDF 和 DAML+OIL 图示,生活就是不断的发现新事物,get新技能~

  Uche Ogbuji 继续定义问题跟踪应用程序的 RDF 与 DAML+OIL 图示,继续同以前一样讨论建模。

  在本专栏的上一篇文章中,我讨论了诸如 RDF 这样的 XML 知识管理系统是如何另辟蹊径解决数据设计与建模这些老问题的。我的目的是要准确说明问题跟踪程序包的模式,我曾使用问题跟踪程序包来演示将 RDF 同 XML 应用程序一起使用。现在,我将以 RDFS 和 DAML+OIL 形式完成问题跟踪程序模式的定义。

  这里,同样需要熟悉 RDF、RDFS 和 DAML+OIL。写完上一篇文章之后,我已与同事 Roxane Ouellet 一起发表了 DAML+OIL 简介(请参阅 参考资料),因此,您再也不用埋头翻阅厚厚的规范来掌握它了。

  请继续

  言归正传,下面给出的清单 1 是问题跟踪程序的完整 RDFS。

  清单 1. 问题跟踪程序的 RDFS 模式

  

?xml version="1.0" encoding="UTF-8"?!DOCTYPE rdf:RDF [!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#"!ENTITY it "http://rdfinference.org/schemata/issue-tracker/"!ENTITY dc "http://purl.org/dc/elements/1.1/"]rdf:RDFxmlns:rdf="&rdf;"xmlns:rdfs="&rdfs;"xmlns:it="⁢"rdfs:Class rdf:about="⁢Catalog"rdfs:labelIssue catalog/rdfs:labelrdfs:commentAn optional collection of resources for which issues have or canbe defined. Use dc:relation to associate the catalog with itsresources./rdfs:comment/rdfs:Classrdfs:Class rdf:about="⁢Issue"rdfs:labelIssue/rdfs:labelrdfs:commentA problem, suggestion or other matter for action or discussionrelevant to a resource. Use Dublin Core properties for basedescription./rdfs:comment/rdfs:Classrdfs:Property rdf:about="⁢issue"rdfs:labelissue/rdfs:labelrdfs:commentAssociate an issue to its resources/rdfs:commentrdfs:range rdf:resource="⁢Issue"//rdfs:Propertyrdfs:Property rdf:about="⁢action"rdfs:labelaction/rdfs:labelrdfs:commentAssociate an action with an issue/rdfs:commentrdfs:domain rdf:resource="⁢Issue"/rdfs:range rdf:resource="⁢Action"//rdfs:Propertyrdfs:Class rdf:about="⁢Action"rdfs:labelAction/rdfs:labelrdfs:commentAn action to be taken with regard to an issue/rdfs:comment/rdfs:Classrdfs:Class rdf:about="⁢it:assignee"rdfs:labelAssign to/rdfs:labelrdfs:commentSpecify the party to whom the action is assigned/rdfs:commentrdfs:domain rdf:resource="⁢Action"//rdfs:Classrdfs:Class rdf:about="⁢status"rdfs:labelstatus/rdfs:labelrdfs:commentFor instance, "not done" or "done"/rdfs:commentrdfs:domain rdf:resource="⁢Action"//rdfs:Classrdfs:Class rdf:about="⁢comment"rdfs:labelcomment/rdfs:labelrdfs:commentAssociate a comment with an issue/rdfs:commentrdfs:domain rdf:resource="⁢Issue"/rdfs:range rdf:resource="⁢Comment"//rdfs:Classrdfs:Class rdf:about="⁢Comment"rdfs:labelComment/rdfs:labelrdfs:commentA comment made with regard to an issue/rdfs:comment/rdfs:Class/rdf:RDF

  您会注意到发生了一些变化,包括使用的名称空间也发生了变化。遗憾的是,我们不会象解释我们以前的 RDF 示例没有使用任何定义的类那样详尽地解释这些变化。这一模式表示了 RDFInference.org 的问题跟踪程序当前正在使用什么,包括由于各种原因所做的变化。我将稍后提供实例 RDF 的相应更新。

  我也采用了一些词法约定:首先,我将所有的名称空间 URI 定义为 DTD 内部子集中的实体(这一约定是我从 Ouellet 女士那里学来的),这一约定减少了错误并改善了可读性。于是,我只使用 rdf:about ,而不再使用 rdf:ID ,在艰辛地经历了与对包含文档的假设 URI 解析 ID 有关的所有缺陷之后,最近,我采用了这一约定。请注意,只有在能确保有一个显式的 xml:base 声明,以及需要互操作性的所有 RDF 处理程序都支持 XML 基础时,我才使用 rdf:ID 。

  Catalog 类提供了一种方法,来聚合所有拥有问题或允许用户为其创建问题的资源。这主要为应用程序提供便利。请想象一下跟踪程序的一个基于 Web 的表单。它可能有一个感兴趣资源的下拉选择框。一种填充该列表的方法是从给定的目录检查所有 dc:relation 语句的对象。而我将要提供的 DAML+OIL 模式则演示了另外一种方法。

  还有其它几个小小的变化,例如为了词类更一致的使用,将assigned-to重命名为assignee。除此之外,在这一模式中没有什么值得奇怪的,好了,让我们继续了解 DAML+OIL 版本。

  DAML 的特点

  DAML+OIL 是一个模式系统,它提供了对 RDFS 的关键改进,其中包括一个内置的数据类型确定系统、枚举支持、特性专门化以及通过推论进行分类与确定类型。它也超出了纯粹的示意图,它允许我们定义存在(ontology),我们对概念的理解大概就是这样的,但是目前我们主要还是使用基本的示意功能。清单 2 是类似于清单 1 的问题跟踪程序的 DAML+OIL 模式。

  清单 2. 问题跟踪程序的 DAML+OIL 模式

  

?xml version="1.0" encoding="UTF-8"?!DOCTYPE rdf:RDF [!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"!ENTITY xsd "http://www.w3.org/2000/10/XMLSchema#"!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#"!ENTITY daml "http://www.daml.org/2001/03/daml+oil#"!ENTITY dc "http://purl.org/dc/elements/1.1/"!ENTITY it "http://rdfinference.org/schemata/issue-tracker/"]rdf:RDFxmlns:rdf="&rdf;"xmlns:rdfs="&rdfs;"xmlns:daml="&daml;"xmlns:xsd="&xsd;"xmlns:it="⁢"daml:Ontology rdf:about=""daml:versionInfo!-- Note: requires expansion by RCS, CVS or the like$Revision$/daml:versionInfordfs:commentOntology for an issue tracking system for arbitrary resources/rdfs:commentdaml:imports rdf:resource="http://www.w3.org/2001/10/daml+oil"//daml:Ontologydaml:Class rdf:about="⁢RelevantResource"rdfs:labelRelevant resource/rdfs:labelrdfs:commentAn implied classification of resources that have related issues/rdfs:commentrdfs:subClassOfdaml:onProperty rdf:resource="⁢issue"/daml:toClass rdf:resource="⁢Issue"//rdfs:subClassOf/daml:Classdaml:Class rdf:about="⁢Issue"rdfs:labelIssue/rdfs:labelrdfs:commentA problem, suggestion or other matter for action or discussionrelevant to a resource. Use Dublin Core properties for basedescription./rdfs:comment/daml:Classdaml:ObjectProperty rdf:about="⁢issue"rdfs:labelissue/rdfs:labelrdfs:commentAssociate an issue to its resources/rdfs:commentrdfs:range rdf:resource="⁢Issue"//daml:ObjectPropertydaml:ObjectProperty rdf:about="⁢action"rdfs:labelaction/rdfs:labelrdfs:commentAssociate an action with an issue/rdfs:commentrdfs:domain rdf:resource="⁢Issue"/rdfs:range rdf:resource="⁢Action"//daml:ObjectPropertydaml:Class rdf:about="⁢Action"rdfs:labelAction/rdfs:labelrdfs:commentAn action to be taken with regard to anissue/rdfs:comment/daml:Classdaml:ObjectProperty rdf:about="⁢it:assignee"rdfs:labelAssign to/rdfs:labelrdfs:commentSpecify the party to whom the action is assigned/rdfs:commentrdfs:domain rdf:resource="⁢Action"//daml:ObjectPropertydaml:ObjectProperty rdf:about="⁢status"rdfs:labelstatus/rdfs:labelrdfs:commentFor instance, "not done" or "done"/rdfs:commentrdfs:domain rdf:resource="⁢Action"//daml:ObjectPropertydaml:ObjectProperty rdf:about="⁢comment"rdfs:labelcomment/rdfs:labelrdfs:commentAssociate a comment with an issue/rdfs:commentrdfs:domain rdf:resource="⁢Issue"/rdfs:range rdf:resource="⁢Comment"//daml:ObjectPropertydaml:Class rdf:about="⁢Comment"rdfs:labelComment/rdfs:labelrdfs:commentA comment made with regard to an issue/rdfs:comment/daml:Class/rdf:RDF

  存在标题出现在任何定义之前。这是一个 DAML 约定,它描述文档、确定模式(因此使用空的 rdf:about ,它将文档本身设置为主题)。它的一个特征是有一条修订语句,我是使用由修订控制系统扩展的关键字来定义该语句的。其另外一个特征是一个导入,它是由 DAML+OIL 添加的一个显式机制,目的在于将来自其它文件的定义合并到当前文件(在 DAML 出现之前,您要么必须将多个源定义合并成一个模型,要么使用诸如 XInclude 的较低级别的机制)。作为标准实践,我导入核心 DAML+OIL 模式,为特定于 DAML+OIL 的资源添加定义。

  接下来是一个特殊的类 RelevantResource ,它没有显式地声明其实例,而是由对实例特性的推论定义实例。更进一步地研究 RelevantResource 类可以搞清楚这一点。它被定义为匿名内联资源的子类,而匿名内联资源类型又是 daml:Restriction 的类型。这是一个特殊的 DAML+OIL 机制,它允许您根据实例具有的特性以及这些特性的值来定义规则。在这个例子里,约束条件选择所有具有 issue 特性并且该特性的值属于类 Issue 的资源。通过从这一约束条件划分子类, RelevantResource 类成为一种包含一个所有满足该约束条件资源集合的虚拟类。如果在任何时候资源获得具有适当类值的适当特性,那么无需显式声明,它会自动成为这一虚拟类的成员。

  在您可能还没有控制正在操作的所有信息空间时,这是一项非常重要的功能,这也是为什么要推出 DAML+OIL 的缘故,DAML+OIL 的推出在巩固 Semantic Web 的这类技术方面向前跨了一大步。在更恰当的例子中,这一功能允许我们无须为问题跟踪显式地注册所有资源,如同我们以模式的 RDFS 形式(使用 Catalog 类)所做的那样。

  我使用 daml:Class 定义所有的类,它是 rdfs:Class 的子类,而 rdfs:Class 提供 DAML 所引入的所有附加功能。类似地,我使用 daml:ObjectProperty 定义特性。问题跟踪程序模式不使用具体的数据类型(字符串、整数等等)来定义任何特性的值,但是需要说明的是,这些特性在 DAML+OIL 中是作为 daml:DatatypeProperty 的子类定义的。

  DAML+OIL 模式实际上就是在 RDFInference.org 应用程序中所使用的那种模式,而且我们也将它用作本专栏继续下去的基础。

  更新实例

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/webkaifa/)

  由于那些我所提到过的变化,我回顾并更新了到目前为止在本专栏中我们一直在研究的问题的样本实例,请参阅清单 3。

  清单 3. 更新的实例数据

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/webkaifa/)

  

?xml version='1.0'?!DOCTYPE rdf:RDF [!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#"!ENTITY daml "http://www.daml.org/2001/03/daml+oil#"!ENTITY dc "http://purl.org/dc/elements/1.1/"!ENTITY foaf "http://xmlns.com/foaf/0.1/"!ENTITY it "http://rdfinference.org/schemata/issue-tracker/"!ENTITY rit "http://rdfinference.org/ril/issue-tracker/"]rdf:RDFxmlns:rdf="&rdf;"xmlns:rdfs="&rdfs;"xmlns:daml="&daml;"xmlns:rit="&rit;"xmlns:it="⁢"xmlns:dc="&dc;"xmlns:foaf="&foaf;"xmlns="⁢"rdf:Description rdf:about='http://rdfinference.org/ril/ril-20010502'issue rdf:resource='&rit;i2001030423'/issue rdf:resource='&rit;i2001042003'//rdf:DescriptionIssue rdf:about='&rit;i2001030423'dc:titleUnnecessary abbreviation/dc:titledc:creator rdf:resource='mailto:Alexandre.Fayolle@logilab.fr'/dc:descriptionIs the abbreviation of rdf:type predicates in queries necessary?/dc:descriptiondc:date2001-03-04/dc:datecomment rdf:parseType="Resource"dc:creator rdf:resource='mailto:Alexandre.Fayolle@logilab.fr'/dc:descriptionThe abbreviation in listing 8 doesn't seem necessary to NicoChauvat or me./dc:description/commentaction rdf:parseType="Resource"dc:descriptionOrganize a vote on this topic/dc:descriptionit:assignee rdf:resource='mailto:uche.ogbuji@fourthought.com'//action/IssueIssue rdf:about='&rit;i2001042003'dc:titleInconsistent versioning/dc:titledc:creator rdf:resource='mailto:Nicolas.Chauvat@logilab.fr'/dc:descriptionThe RIL versioning is not clear (there's a mix of 0.1, 0/1, 0.2and 0/2)/dc:descriptiondc:date2001-04-20/dc:dateaction rdf:parseType="Resource"dc:descriptionCorrect all to use the "0/1" form in the next draft./dc:descriptionit:assignee rdf:resource='mailto:uche.ogbuji@fourthought.com'//action/Issuerdf:Description rdf:about='mailto:Alexandre.Fayolle@logilab.fr'foaf:nameAlexandre Fayolle/foaf:name/rdf:Descriptionrdf:Description rdf:about='mailto:uche.ogbuji@fourthought.com'foaf:nameUche Ogbuji/foaf:name/rdf:Descriptionrdf:Description rdf:about='mailto:Nicolas.Chauvat@logilab.fr'foaf:nameNicolas Chauvat/foaf:name/rdf:Description/rdf:RDF

展开更多 50%)
分享

猜你喜欢

XML 编程思想:定义 RDF 和 DAML+OIL 图示

Web开发
XML 编程思想:定义 RDF 和 DAML+OIL 图示

XML 编程思想:使用 XSLT 生成 RDF

Web开发
XML 编程思想:使用 XSLT 生成 RDF

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

XML 编程思想:知识管理的基本 XML 和 RDF 技术(7)

Web开发
XML 编程思想:知识管理的基本 XML 和 RDF 技术(7)

XML 编程思想:将文件合并到 RDF 模型和基本的 RDF 查询

Web开发
XML 编程思想:将文件合并到 RDF 模型和基本的 RDF 查询

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

XML 编程思想:使用 Versa 的 RDF 查询

Web开发
XML 编程思想:使用 Versa 的 RDF 查询

XML 编程思想:XML和语义

Web开发
XML 编程思想:XML和语义

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

Win10正式版有什么亮点?

Win10正式版有什么亮点?

CSS常用样式效果

CSS常用样式效果
下拉加载更多内容 ↓