XML Design - (A Gentle Transition from XML to RDF)(一个很好的关于RDF的slides)

[推荐]XML Design - (A Gentle Transition from XML to RDF) (一个很好的关于RDF的slides)

Roger L. Costello
, David B. Jacobs
The MITRE Corporation
(The creation of this tutorial was sponsored by DARPA)
2003

 

这个ppt全面地介绍了RDF的内容,着重于比较XMLRDF的区别,有比较丰富的示例,明白易懂,RDF入门的好材料. 文档里的练习过一段实践可以再做一遍,加深印象.

 


1. 一个基本的 RDF 文件

<?xml version="1.0"?>

<River rdf:ID="Yangtze"

            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

            xmlns="http://www.geodesy.org/river#">

     <length>6300 kilometers</length>

     <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation>

     <endingLocation>East China Sea</endingLocation>

</River>

 

2. xml:base

表明当前rdf文档的位置”, 由此文档中描述的资源可以被引用

<?xml version="1.0"?>

<River rdf:ID="Yangtze"

            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

            xmlns="http://www.geodesy.org/river#"

            xml:base="http://www.china.org/geography/rivers">

     <length>6300 kilometers</length>

     <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation>

     <endingLocation>East China Sea</endingLocation>

</River>

 


3. RDF 中的命名规则

type(class)由大写字母开头

property由小写字母开头


4. 3种等价的RDF文档表示方法

(1)

<?xml version="1.0"?>

<River rdf:ID="Yangtze"

            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

            xmlns="http://www.geodesy.org/river#"

            xml:base="http://www.china.org/geography/rivers">

     <length>6300 kilometers</length>

     <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation>

     <endingLocation>East China Sea</endingLocation>

</River>

 

(2)

<?xml version="1.0"?>

<River rdf:about="http://www.china.org/geography/rivers#Yangtze"

            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

            xmlns="http://www.geodesy.org/river#">

     <length>6300 kilometers</length>

     <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation>

     <endingLocation>East China Sea</endingLocation>

</River>

 

(3)

<?xml version="1.0"?>

<rdf:Description rdf:about="http://www.china.org/geography/rivers#Yangtze"

                             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

                             xmlns="http://www.geodesy.org/river#">

     <rdf:type rdf:resource="http://www.geodesy.org/river#River"/>

     <length>6300 kilometers</length>

     <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation>

     <endingLocation>East China Sea</endingLocation>

</rdf:Description>

 

rdf:ID rdf:about 的区别:

前者通常用来定义一个资源;后者通常用来扩展这个资源的信息.

 

5. 引用其它地方定义的 Resource

假设已经定义了:

<?xml version="1.0"?>

<Dam rdf:ID="ThreeGorges"

            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

           xmlns="http://www.geodesy.org/dam#"

           xml:base="http://www.china.org/geography/rivers">

     <name>The Three Gorges Dam</name>

     <width>1.5 miles</width>

     <height>610 feet</height>

     <cost>$30 billion</cost>

</Dam>

 

在下面的 RDF 文档里引用 ThreeGorges 这个 Resource:

<?xml version="1.0"?>

<River rdf:ID="Yangtze"

            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

            xmlns="http://www.geodesy.org/river#"

            xml:base="http://www.china.org/geography/rivers">

     <length>6300 kilometers</length>

     <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation>

     <endingLocation>East China Sea</endingLocation>

     <obstacle rdf:resource="http://www.china.org/geography/rivers#ThreeGorges"/>

</River>

 

6. 使用 aggregator tool 可以收集关于一个资源的分散的信息 .

 

7. anonymous resource

<?xml version="1.0"?>

<River rdf:ID="Yangtze"

            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

            xmlns="http://www.geodesy.org/river#"

            xmlns:uom="http://www.measurements.org/units-of-measure#">

     <length>

          <rdf:Description>

               <rdf:value>6300</rdf:value>

               <uom:units>kilometers</uom:units>

          </rdf:Description>

     </length>

     <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation>

     <endingLocation>East China Sea</endingLocation>

</River>

 

或写成 :

<?xml version="1.0"?>

<River rdf:ID="Yangtze"

            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

            xmlns="http://www.geodesy.org/river#"

            xmlns:uom="http://www.measurements.org/units-of-measure#">

     <length rdf:parseType="Resource">

               <rdf:value>6300</rdf:value>

               <uom:units>kilometers</uom:units>

     </length>

     <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation>

     <endingLocation>East China Sea</endingLocation>

</River>

 

8. RDF Model

clip_image002%5B2%5D%5B1%5D%5B1%5D.jpg

 

9. rdf:datatype

<?xml version="1.0"?>

<River rdf:ID="Yangtze"

            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

            xmlns="http://www.geodesy.org/river#">

     <length rdf:datatype="http://www.uom.org/distance#kilometer">6300</length>

     <maxWidth rdf:datatype="http://www.uom.org/distance#meter">175</maxWidth>

     <maxDepth rdf:datatype="http://www.uom.org/distance#meter">55</maxDepth>

</River>

 

datatype uom.xsd 里定义 :

<?xml version="1.0" encoding="UTF-8"?>

<schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"

               targetNamespace="http://www.uom.org/distance#">

    <simpleType name="kilometer">

        <restriction base="integer">

        </restriction>

    </simpleType>

     <simpleType name="meter">

        <restriction base="integer">

        </restriction>

    </simpleType>

</schema>

 

10. rdf:Bag/Alt/Seq class

(1) rdf:Bag class

无序集合

e.g.

<?xml version="1.0"?>

<Meeting rdf:ID="XML-Design-Pattern"

                xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

                xmlns="http://www.business.org#">

     <attendees>

          <rdf:Bag>

               <rdf:li>John Smith</rdf:li>

               <rdf:li>Sally Jones</rdf:li>

          </rdf:Bag>

     </attendees>

</Meeting>

 

(2) rdf:Alt class

一个集合中任一资源

 

(3) rdf:Seq class

有先后顺序的property

 

(4) rdf:li

用来标识Bag/Alt/Seq里的一个item

 

11. rdf:parseType="Collection"

This may be added as an attribute of a property to indicate that the contents of the property is a list of resources.

 

rdf:parseType="Collection" rdf:Bag/Alt/Seq 的区别 ?

rdf:Bag/Alt/Seq都属于容器,容器的一个缺点是没有办法封闭它,即没有办法说这些是容器的所有成员。一个容器只说一些有标识的资源是它的成员,无法说没有其他的成员了。而且,如果有一个图描述它的一些成员,我们没法排除在其他地方有图也描述这个容器的其它成员的可能。RDFRDF集合(collection)的形式提供了对描述特定成员的组的支持。一个RDF集合是用列表结构表示的一组事物,这个列表结构是用一些预定义的集合词汇表示的。

 

12. rdf:parseType="Literal"

使用这个属性会使内容失去resource/property/value的结构,应该尽量少用.

 

13. 结论

推荐所有的XML文档都符合RDF规范.

 

14. 注意事项 :
(1) RDF
文档中的跟资源不应该是匿名的 , 否则就没有意义了 .
(2) RDF
property 不能有 attribute(RDF attribute 除外 ).

转载于:https://www.cnblogs.com/yuquanlaobo/archive/2007/01/07/614221.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值