Roger L Costello David B Jacobs 2003 The
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. XML Design (A Gentle Transition from XML to RDF) Roger L. Costello David B. Jacobs The MITRE Corporation (The creation of this tutorial was sponsored by DARPA) 1
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Acknowledgments • We are very grateful to the Defense Agency Research Projects Agency (DARPA) for funding the creation of this tutorial. We are especially grateful to Murray Burke (DARPA) and John Flynn (BBN) for making it all happen. • Special thanks to Frank Manola for answering our many questions. 2
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. What is the Purpose of RDF? • The purpose of RDF (Resource Description Framework) is to give a standard way of specifying data "about" something. • Here's an example of an XML document that specifies data about China's Yangtze river: <? xml version="1. 0"? > <River id="Yangtze" xmlns="http: //www. geodesy. org/river"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> "Here is data about the Yangtze River. It has a length of 6300 kilometers. Its starting. Location is western China's Qinghai-Tibet Plateau. Its ending. Location is the East China Sea. " 3
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 4 XML --> RDF Modify the following XML document so that it is also a valid RDF document: XML <? xml version="1. 0"? > <River id="Yangtze" xmlns="http: //www. geodesy. org/river"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> Yangtze. xml "convert to" RDF <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> Yangtze. rdf
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 5 The RDF Format 1 RDF provides an ID attribute for identifying the resource being described. 2 The ID attribute is in the RDF namespace. <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> 3 Add the "fragment identifier symbol" to the namespace.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 6 The RDF Format (cont. ) 2 Identifies the resource being described. This resource is an instance of River. 1 Identifies the type (class) of the resource being described. 3 These are properties, or attributes, of the type (class). <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> 4 Values of the properties
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 7 Namespace Convention Question: Why was "#" placed onto the end of the namespace? E. g. , Answer: RDF is very concerned about uniquely identifying things uniquely identifying the type (class) and uniquely identifying the properties. If we concatenate the namespace with the type then we get a unique identifier for the type, e. g. , http: //www. geodesy. org/river#River Best Practice xmlns="http: //www. geodesy. org/river#" If we concatenate the namespace with a property then we get a unique identifier for the property, e. g. , http: //www. geodesy. org/river#length http: //www. geodesy. org/river#starting. Location http: //www. geodesy. org/river#ending. Location Thus, the "#" symbol is simply a mechanism for separating the namespace from the type name and the property name.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. The RDF Format <? xml version="1. 0"? > <Class rdf: ID="Resource" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="uri"> <property>value</property>. . . </Class> 8
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Interoperability Advantage of using the RDF Format • You may ask: "Why should I bother designing my XML to be in the RDF format? " • Answer: there are numerous benefits: – The RDF format, if widely used, will help to make XML more interoperable: Network effect • Tools can instantly characterize the structure, "this element is a type (class), and here are its properties”. • RDF promotes the use of standardized vocabularies. . . standardized types (classes) and standardized properties. – The RDF format gives you a structured approach to designing your XML documents. The RDF format is a regular, recurring pattern. – It enables you to quickly identify weaknesses and inconsistencies of non. RDF-compliant XML designs. It helps you to better understand your data! – You reap the benefits of both worlds: • You can use standard XML editors and validators to create, edit, and validate your XML. • You can use the RDF tools to apply inferencing to the data. – It positions your data for the Semantic Web! 9
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Disadvantage of using the RDF Format • Constrained: the RDF format constrains you on how you design your XML (i. e. , you can't design your XML in any arbitrary fashion). • RDF uses namespaces to uniquely identify types (classes), properties, and resources. Thus, you must have a solid understanding of namespaces. • Another XML vocabulary to learn: to use the RDF format you must learn the RDF vocabulary. 10
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Uniquely Identify the Resource • Earlier we said that RDF is very concerned about uniquely identifying the type (class) and the properties. RDF is also very concerned about uniquely identifying the resource, e. g. , This is the resource being described. We want to uniquely identify this resource. <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> 11
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 12 rdf: ID • The value of rdf: ID is a "relative URI". • The "complete URI" is obtained by concatenating the URL of the XML document with "#" and then the value of rdf: ID, e. g. , <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> Yangtze. rdf Suppose that this RDF/XML document is located at this URL: http: //www. china. org/geography/rivers. Thus, the complete URI for this resource is: http: //www. china. org/geography/rivers#Yangtze
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. xml: base • • • On the previous slide we showed how the URL of the document provided the base URI. Depending on the location of the document is brittle: it will break if the document is moved, or is copied to another location. A more robust solution is to specify the base URI in the document, e. g. , <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. 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> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> Resource URI = concatenation(xml: base, '#', rdf: ID) = concatenation(http: //www. china. org/geography/rivers, '#', "Yangtze") = http: //www. china. org/geography/rivers#Yangtze 13
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. rdf: about • Instead of identifying a resource with a relative URI (which then requires a base URI to be prepended), we can give the complete identity of a resource. However, we use rdf: about, rather than rdf: ID, e. g. , <? xml version="1. 0"? > <River rdf: about="http: //www. china. org/geography/rivers#Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> 14
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 15 Triple -> resource/property/value http: //www. china. org/geography/rivers#Yangtze has a http: //www. geodesy. org/river#length of 6300 kilometers resource property value http: //www. china. org/geography/rivers#Yangtze has a http: //www. geodesy. org/river#starting. Location of western China's. . . resource property value http: //www. china. org/geography/rivers#Yangtze has a http: //www. geodesy. org/river#ending. Location of East China Sea resource property value
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 16 The RDF Format = triples! • The fundamental design pattern of RDF is to structure your XML data as resource/property/value triples! value of property-A value of property-B <? xml version="1. 0"? > <Resource-A> <property-A> <Resource-B> <property-B> <Resource-C> <property-C> Value-C </property-C> </Resource-C> </property-B> </Resource-B> </property-A> </Resource-A> Notice that the RDF design pattern is an alternating sequence of resource-property. This pattern is known as "striping". The value of a property can be a literal (e. g. , length has a value of 6300 kilometers). Also, the value of a property can be a resource, as shown above (e. g. , property-A has a value of Resource-B, property-B has a value of Resource-C). We will see examples of properties having a resource value in a little bit.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Naming Convention • The convention is to use a capital letter to start a type (class) name, and use a lowercase letter to start a property name. – This helps the eye quickly discern the striping pattern. uppercase lowercase <? xml version="1. 0"? > <River rdf: about="http: //www. china. org/geography/rivers#Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> 17
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. RDF Model (graph) Legend: Ellipse indicates "Resource" Rectangle indicates "literal string value" 18
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 19 rdf: Description + rdf: type • There is still another way of representing the XML. This way makes it very clear that you are describing something, and it makes it very clear what the type (class) is of the thing you are describing: <? xml version="1. 0"? > <rdf: Description rdf: about="http: //www. china. org/geography/rivers#Yangtze" xmlns: rdf="http: //www. w 3. 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> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </rdf: Description> This is read as: "This is a Description about the resource http: //www. china. org/geography/rivers#Yangtze. This resource is an instance of the River type (class). The http: //www. china. org/geography/rivers#Yangtze resource has a length of 6300 kilometers, a starting. Location of western China's Qinghai-Tibet Plateau, and an ending. Location of the East China Sea. " Note: this form of describing a resource is called the "long form". The form we have seen previously is an abbreviation of this long form. An RDF Parser interprets the abbreviated form as if it were this long form.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Alternative • Alternatively we can use rdf: ID rather than rdf: about, as shown here: <? xml version="1. 0"? > <rdf: Description rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#" xml: base="http: //www. china. org/geography/rivers"> <rdf: type rdf: resource="http: //www. geodesy. org/river#River"/> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </rdf: Description> 20
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 21 Equivalent Representations! <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. 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> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> <? xml version="1. 0"? > <River rdf: about="http: //www. china. org/geography/rivers#Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> <? xml version="1. 0"? > <rdf: Description rdf: about="http: //www. china. org/geography/rivers#Yangtze" xmlns: rdf="http: //www. w 3. 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> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </rdf: Description> Note: In the RDF literature the examples are typically shown in this form.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 22 RDF Namespace http: //www. w 3. org/1999/02/22 -rdf-syntax-ns# ID about type resource Description
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 23 Terminology • As you read the RDF literature you may see the following terminology: – Subject: this term refers to the item that is playing the role of the resource. – predicate: this term refers to the item that is playing the role of the property. – Object: this term refers to the item that is playing the role of the value. Subject predicate Object Equivalent! Resource property Value
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 24 RDF Parser • There is a nice RDF parser at the W 3 Web site: http: //www. w 3. org/RDF/Validator/ This RDF parser will tell you if your XML is in the proper RDF format. Do Lab 1
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 25 Example #2 Modify the following XML document so that it is RDF-compliant: <? xml version="1. 0"? > <River id="Yangtze" xmlns="http: //www. geodesy. org/river"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> <Dam id="Three. Gorges" xmlns="http: //www. geodesy. org/dam"> <name>The Three Gorges Dam</name> <width>1. 5 miles</width> <height>610 feet</height> <cost>$30 billion</cost> </Dam> </River> Yangtze 2. xml
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 26 Note the two types (classes) River Instance: Yangtze Properties: length starting. Location ending. Location Dam Instance: Three. Gorges Properties: name width height cost
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Dam - out of place Dam <? xml version="1. 0"? > <River id="Yangtze" xmlns="http: //www. geodesy. org/river"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> <Dam id="Three. Gorges" xmlns="http: //www. geodesy. org/dam"> <name>The Three Gorges Dam</name> <width>1. 5 miles</width> <height>610 feet</height> <cost>$30 billion</cost> </Dam> </River> Types (classes) contain properties. Here we see the River type containing the properties - length, starting. Location, and ending. Location. It also shows River containing a type - Dam. Thus, there is a Resource that contains another Resource. This is inconsistent with RDF design pattern. (We are seeing one of the benefits of using the RDF format - to identify inconsistencies in an XML design. ) 27
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Property value must be a Literal or a Resource <length>6300 kilometers</length> property Value is a Literal property Value is a Resource <obstacle> <Dam id="Three. Gorges" xmlns="http: //www. geodesy. org/dam"> <name>The Three Gorges Dam</name> <width>1. 5 miles</width> <height>610 feet</height> <cost>$30 billion</cost> </Dam> </obstacle> 28
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Modified XML (to make it consistent) <? xml version="1. 0"? > <River id="Yangtze" xmlns="http: //www. geodesy. org/river"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> <obstacle> <Dam id="Three. Gorges" xmlns="http: //www. geodesy. org/dam"> <name>The Three Gorges Dam</name> <width>1. 5 miles</width> <height>610 feet</height> <cost>$30 billion</cost> </Dam> </obstacle> </River> Yangtze 2, v 2. xml "The Yangtze River has an obstacle that is the Three. Gorges Dam. The Dam has a name - The Three Gorges Dam. It has a width of 1. 5 miles, a height of 610 feet, and a cost of $30 billion. " 29
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 30 RDF Format <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. 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> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> <obstacle> <Dam rdf: ID="Three. Gorges" xmlns="http: //www. geodesy. org/dam#"> <name>The Three Gorges Dam</name> <width>1. 5 miles</width> <height>610 feet</height> <cost>$30 billion</cost> </Dam> </obstacle> </River> Changed id to rdf: ID Added the '#' symbol As always, the other representations using rdf: about and rdf: Description are available.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. RDF Model (graph) 31
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Alternatively, suppose that someone has already created a document containing information about the Three Gorges Dam: <? xml version="1. 0"? > <Dam rdf: ID="Three. Gorges" xmlns: rdf="http: //www. w 3. 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> Three-Gorges-Dam. rdf Then we can simply reference the Three Gorges Dam resource using rdf: resource, as shown here: <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. 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> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> <obstacle rdf: resource="http: //www. china. org/geography/rivers#Three. Gorges"/> </River> Yangtze. rdf 32
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 33 Note: reference is to a resource, not to a file Why was this the reference: <obstacle rdf: resource="http: //www. china. org/geography/rivers #Three. Gorges"/> and not this: <obstacle rdf: resource="http: //www. china. org/geography/rivers /Three-Gorges-Dam. rdf"/> That is, why wasn't the reference to a "file"? Answer: 1. What if the file moved? Then the reference would break. 2. By using an identifier of the Three Gorges Dam, and keeping a particular file unspecified, then an "aggregator tool" will be able to collect information from all the files that talk about the Three Gorges Dam resource (see next slide). Do Lab 2
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Anyone, Anywhere, Anytime Can Talk About a Resource • In all of our examples we have provided a unique identifier to resources, e. g. , http: //www. china. org/geography/rivers#Yangtze • Consequently, if another RDF document identifies the same resource then the data that it specifies gives additional data about that resource. • An aggregator tool will be able to collect all data about a resource and present a consolidated set of data for the resource. That's powerful! 34
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. rdf: ID versus rdf: about • When should rdf: ID be used? When should rdf: about be used? – When you want to introduce a resource, and provide an initial set of information about a resource use rdf: ID – When you want to extend the information about a resource use rdf: about • The RDF philosophy is akin to the Web philosophy. That is, anyone, anywhere, anytime can provide information about a resource. 35
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 36 <? xml version="1. 0"? > <River rdf: about="http: //www. china. org/geography/rivers#Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> http: //www. china. org/geography/rivers/yangtze. rdf <? xml version="1. 0"? > <River rdf: about="http: //www. china. org/geography/rivers#Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#"> <name>Dri Chu - Female Yak River</name> <name>Tongtian He, Travelling-Through-the-Heavens River</name> <name>Jinsha Jiang, River of Golden Sand</name> </River> http: //www. encyclopedia. org/yangtze-alternate-names. rdf Aggregator tool collects data about the Yangtze <? xml version="1. 0"? > <River rdf: about="http: //www. china. org/geography/rivers#Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> <name>Dri Chu - Female Yak River</name> <name>Tongtian He, Travelling-Through-the-Heavens River</name> <name>Jinsha Jiang, River of Golden Sand</name> </River> Aggregated Data! A distributed network of data!
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. <? xml version="1. 0"? > <Dam rdf: ID="Three. Gorges" xmlns: rdf="http: //www. w 3. 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> 37 Another Example of Aggregation http: //www. encyclopedia. org/three-gorges-dam. rdf Aggregate! <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. 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> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> <obstacle rdf: resource="http: //www. china. org/geography/rivers #Three. Gorges"/> </River> http: //www. china. org/geography/rivers/yangtze. rdf <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. 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> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> <obstacle> <Dam rdf: ID="Three. Gorges" xmlns="http: //www. geodesy. org/dam#"> <name>The Three Gorges Dam</name> <width>1. 5 miles</width> <height>610 feet</height> <cost>$30 billion</cost> </Dam> </obstacle> </River> Note that the reference to the Three. Gorges Dam resource has been replaced by whatever information the aggregator could find on this resource!
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 38 Example #3 Notice that in this XML document there is no unique identifier: XML <? xml version="1. 0"? > <River xmlns="http: //www. geodesy. org/river#"> <name>Yangtze</name> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> Yangtze 3. xml RDF <? xml version="1. 0"? > <River xmlns="http: //www. geodesy. org/river#"> <name>Yangtze</name> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> Yangtze 3. rdf The RDF is identical to the XML!
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Interpreting the RDF <? xml version="1. 0"? > <River xmlns="http: //www. geodesy. org/river#"> <name>Yangtze</name> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> Yangtze 3. rdf This is read as: "This is an instance of the River type (class). The River has a name of Yangtze, a length of 6300 kilometers, a starting. Location of western China's Qinghai-Tibet Plateau, and an ending. Location of the East China Sea. " In this document the resource is anonymous - it has no identifier. 39
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Disadvantage of anonymous resources 40 <? xml version="1. 0"? > <River xmlns="http: //www. geodesy. org/river#"> <name>Yangtze</name> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> http: //www. china. org/geography/rivers/yangtze. rdf <? xml version="1. 0"? > <River xmlns="http: //www. geodesy. org/river#"> <name>Yangtze</name> <name>Dri Chu - Female Yak River</name> <name>Tongtian He, Travelling-Through-the-Heavens River</name> <name>Jinsha Jiang, River of Golden Sand</name> </River> http: //www. encyclopedia. org/yangtze-alternate-names. rdf Aggregate An aggregator tool will not be able to determine if these documents are talking about the same resource.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Example #4 XML <? xml version="1. 0"? > <River id="Yangtze" xmlns="http: //www. geodesy. org/river" xmlns: uom="http: //www. measurements. org/units-of-measure"> <length uom: units="kilometers">6300</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> Yangtze 4. xml RDF <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. 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> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> Yangtze 4. rdf 41
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 42 <? xml version="1. 0"? > <River id="Yangtze" xmlns="http: //www. geodesy. org/river" xmlns: uom="http: //www. measurements. org/units-of-measure#"> <length uom: units="kilometers">6300</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> Yangtze 4. xml RDF does not allow attributes on the properties (except for special RDF attributes such as rdf: resource). So we need to make the uom: units attribute a child element. Your first instinct might be to modify length to have two child elements: <? xml version="1. 0"? > <River id="Yangtze" xmlns="http: //www. geodesy. org/river" xmlns: uom="http: //www. measurements. org/units-of-measure#"> <length> <value>6300</value> <uom: units>kilometers</uom: units> </length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> However, now the length property has as its value two values. RDF only binary relations i. e. , a single value for a property.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 43 rdf: value 6300 length kilometers length has two values - 6300 and kilometers. RDF provides a special property, rdf: value, to be used for specifying the "primary" value. In this example, 6300 is the primary value, and kilometers is a value which provides additional information about the primary value.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 44 RDF Format An anonymous resource <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. 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> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> Yangtze 4. rdf Read this as: "The Yangtze River has a length whose value is a resource which has a value of 6300 and whose units is kilometers.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Advantage of anonymous resources <rdf: Description> <rdf: value>6300</rdf: value> <uom: units>kilometers</uom: units> </rdf: Description> This is an anonymous resource. Its purpose is solely to provide a context for the two properties. Other RDF documents will have no need to amplify this resource. So, in this case, there is no reason for giving the resource an identifier. In this case it makes good sense to use an anonymous resource. 45
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. RDF Model (graph) Legend: An anonymous resource (also called a "blank node"). That is, a resource with no identifier. (Note: RDF Parsers will typically generate a unique identifier for anonymous resources, to distinguish one anonymous resource from another. ) 46
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. rdf: parse. Type="Resource" If the value of a property is comprised of several values then one option is to create an anonymous resource, as we saw. RDF provides a shorthand, so that you don't need to create an rdf: Description element, by using rdf: parse. Type="Resource", as shown here: <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#" xmlns: uom="http: //www. measurements. org/units-of-measure#"> <length rdf: parse. Type="Resource"> <rdf: value>6300</rdf: value> <uom: units>kilometers</uom: units> </length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> Yangtze 4, v 2. rdf The meaning of this is identical to that shown on the previous slide. 47
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 48 Equivalent! <length> <rdf: Description> <rdf: value>6300</rdf: value> <uom: units>kilometers</uom: units> </rdf: Description> </length> <length rdf: parse. Type="Resource"> <rdf: value>6300</rdf: value> <uom: units>kilometers</uom: units> </length> Do Lab 3
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 49 Summary Modify the following XML document so that it is also a valid RDF document: <? xml version="1. 0"? > <River id="Yangtze" xmlns="http: //www. geodesy. org/river" xmlns: uom="http: //www. measurements. org/units-of-measure#"> <length uom: units="kilometers">6300</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> <Dam id="Three. Gorges" xmlns="http: //www. geodesy. org/dam"> <name>The Three Gorges Dam</name> <width>1. 5 miles</width> <height>610 feet</height> <cost>$30 billion</cost> </Dam> </River> Yangtze. xml See next slide -->
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 50 RDF Format! <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#" xmlns: uom="http: //www. measurements. org/units-of-measure#" xml: base="http: //www. china. org/geography/rivers"> <length rdf: parse. Type="Resource"> <rdf: value>6300</rdf: value> <uom: units>kilometers</uom: units> </length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> <obstacle> <Dam rdf: ID="Three. Gorges" xmlns="http: //www. geodesy. org/dam#"> <name>The Three Gorges Dam</name> <width>1. 5 miles</width> <height>610 feet</height> <cost>$30 billion</cost> </Dam> </obstacle> </River> Yangtze. rdf With relatively few changes the XML document is now usable by both XML tools and RDF tools!
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 51 Example #5 Modify the following XML document so that it is also a valid RDF document: <? xml version="1. 0"? > <River id="Yangtze" xmlns="http: //www. geodesy. org/river" xmlns: uom="http: //www. measurements. org/units-of-measure#"> <length uom: units="kilometers">6300</length> <max. Width uom: units="meters">175</max. Width> <max. Depth uom: units="meters">55</max. Depth> </River> Yangtze 5. xml <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#" xmlns: uom="http: //www. measurements. org/units-of-measure#"> <length rdf: parse. Type="Resource"> <rdf: value>6300</rdf: value> <uom: units>kilometers</uom: units> </length> <max. Width rdf: parse. Type="Resource"> <rdf: value>175</rdf: value> <uom: units>meters</uom: units></max. Width> <max. Depth rdf: parse. Type="Resource"> <rdf: value>55</rdf: value> <uom: units>kilometers</uom: units> </max. Depth> </River> Yangtze 5. rdf This is one way of doing it. Now we will see a better way - using "typed literals". (See next slide)
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Alternate RDF Format <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#"> <length rdf: datatype="http: //www. uom. org/distance#kilometer">6300</length> <max. Width rdf: datatype="http: //www. uom. org/distance#meter">175</max. Width> <max. Depth rdf: datatype="http: //www. uom. org/distance#meter">55</max. Depth> </River> Yangtze 5. rdf With rdf: datatype you can give a property's value a datatype label. The rdf: datatype value acts as a semantic label for the datatype of the value. This is called a typed literal. For this example there must be a namespace, http: //www. uom. org/distance#, which defines two datatypes - kilometer and meter. On the next slide is shown how to do this using XML Schemas. 52
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Defining the kilometer and meter datatypes using XML Schemas <? xml version="1. 0" encoding="UTF-8"? > <schema xmlns: xsd="http: //www. w 3. org/2001/XMLSchema" target. Namespace="http: //www. uom. org/distance#"> <simple. Type name="kilometer"> <restriction base="integer"> </restriction> </simple. Type> <simple. Type name="meter"> <restriction base="integer"> </restriction> </simple. Type> </schema> uom. xsd 53
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Another example using rdf: datatype <? xml version="1. 0"? > <Person rdf: ID="John. Smith" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. person. org#"> <age rdf: datatype="http: //www. w 3. org/2001/XMLSchema#non. Negative. Integer">30</age> </Person> In this example we are specifying that the value (30) of age is a non. Negative. Integer (which is defined in the XML Schema namespace). 54
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Example #6 Modify the following XML document so that it is also a valid RDF document: <? xml version="1. 0"? > <Weather. Reading xmlns="http: //www. meteorology. org#"> <Weather> <temperature>-2 degrees Celsius</temperature> <barometer>30. 4 (rising)</barometer> </Weather> <Location xmlns="http: //www. geodesy. org#"> <country>USA</country> <state>Massachusetts</state> <city>Boston</city> </Location> <datetime>January 22, 2003, 11: 15 EST</datetime> </Weather. Reading> WMUR_TV_Weather. Reading. xml 55
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 56 Things to note 1. The XML document is using three types (classes): Weather. Reading Weather Location 2. The 3 type instances are anonymous. Consequently, we cannot benefit from others, and others cannot benefit from us. Where does it make sense to give an identifier to an instance? - In general, the root element should have an identifier. - There is lots of information about Boston. Let's give the Location instance an identifier.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Modification 1: Identifiers added <? xml version="1. 0"? > <Weather. Reading id="BOS-012203 -1115" xmlns="http: //www. meteorology. org#"> <Weather> <temperature>-2 degrees Celsius</temperature> <barometer>30. 4 (rising)</barometer> </Weather> <Location id="BOS" xmlns="http: //www. geodesy. org#"> <country>USA</country> <state>Massachusetts</state> <city>Boston</city> </Location> <datetime>January 22, 2003, 11: 15 EST</datetime> </Weather. Reading> WMUR_TV_Weather. Reading, v 2. xml 57
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Modification 2: Create a property for the Weather, Location types Types (classes) contain properties. We need to wrap the Weather and Location types within a property: <? xml version="1. 0"? > <Weather. Reading id="BOS-012203 -1115" xmlns="http: //www. meteorology. org#"> <instrument. Reading> <Weather> <temperature>-2 degrees Celsius</temperature> <barometer>30. 4 (rising)</barometer> </Weather> </instrument. Reading> <instrument. Location> <Location id="BOS" xmlns="http: //www. geodesy. org#"> <country>USA</country> <state>Massachusetts</state> <city>Boston</city> </Location> </instrument. Location> <datetime>January 22, 2003, 11: 15 EST</datetime> </Weather. Reading> WMUR_TV_Weather. Reading, v 3. xml 58
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. RDF Format! <? xml version="1. 0"? > <Weather. Reading rdf: ID="BOS-012203 -1115" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. meteorology. org#" xml: base="http: //www. wmur-tv. com/weather"> <instrument. Reading> <Weather> <temperature>-2 degrees Celsius</temperature> <barometer>30. 4 (rising)</barometer> </Weather> </instrument. Reading> <instrument. Location> <Location rdf: ID="BOS" xmlns="http: //www. geodesy. org#" xml: base="http: //www. airports. org/icao"> <country>USA</country> <state>Massachusetts</state> <city>Boston</city> </Location> </instrument. Location> <datetime>January 22, 2003, 11: 15 EST</datetime> </Weather. Reading> WMUR_TV_Weather. Reading. rdf 59
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. The rdf: Bag type (class) • The rdf: Bag type is used to represent an unordered collection. 60
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 61 Example #7 Modify the following XML document so that it is also a valid RDF document: <? xml version="1. 0"? > <Meeting id="XML-Design-Patterns" xmlns="http: //www. business. org"> <attendees> <name>John Smith</name> <name>Sally Jones</name> </attendees> </Meeting> Design. Meeting. xml <? xml version="1. 0"? > <Meeting rdf: ID="XML-Design-Pattern" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. business. org#"> <attendees> <rdf: Bag> <name>John Smith</name> <name>Sally Jones</name> </rdf: Bag> </attendees> </Meeting> Design. Meeting. rdf: Bag makes it clear that this is an unordered collection of names.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. The rdf: Alt type (class) • The rdf: Alt type is used to represent a set of alternate properties. 62
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 63 Example #8 Modify the following XML document so that it is also a valid RDF document: <? xml version="1. 0"? > <Retailer id="Barnes. And. Noble" xmlns="http: //www. retailers. org"> <web. Location> <url>http: //www. bn. com</url> <url>http: //www. barnesandnoble. com</url> </web. Location> </Retailer> Barnes. And. Noble. xml <? xml version="1. 0"? > <Retailer rdf: ID="Barnes. And. Noble" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. retailers. org#"> <web. Location> <rdf: Alt> <url>http: //www. bn. com</url> <url>http: //www. barnesandnoble. com</url> </rdf: Alt> </web. Location> </Retailer> Barnes. And. Noble. rdf: Alt makes it clear that the urls listed are alternates, i. e. , choose one of them.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. The rdf: Seq type (class) • The rdf: Seq type is used to represent a sequence of properties. 64
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 65 Example #9 Modify the following XML document so that it is also a valid RDF document: <? xml version="1. 0"? > <To. Do. List id="Monday. Meetings" xmlns="http: //www. reminders. org"> <activities> <activity 1>Meet with CEO at 10 am</activity 1> <activity 2>Luncheon at The Eatery</activity 2> <activity 3>Flight at 3 pm</activity 3> </activities> </To. Do. List> My. Days. Activities. xml <? xml version="1. 0"? > <To. Do. List rdf: ID="Monday. Meetings" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. reminders. org#"> <activities> <rdf: Seq> <activity 1>Meet with CEO at 10 am</activity 1> <activity 2>Luncheon at The Eatery</activity 2> <activity 3>Flight at 3 pm</activity 3> </rdf: Seq> </activities> </To. Do. List> My. Days. Activities. rdf: Seq makes it clear that the activities listed are to be done in the sequence listed.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. rdf: li Property • The property, rdf: li ("list item"), is provided by RDF for use with either rdf: Bag, rdf: Alt, or rdf: Seq. • The rdf: li property is provided for you to specify an item in a Bag/Alt/Seq. • An RDF Parser will replace each rdf: li with rdf: _1, rdf: _2, rdf: _3, etc. • The following slide recasts the previous examples using the rdf: li property. 66
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. <? xml version="1. 0"? > <Retailer rdf: ID="Barnes. And. Noble" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. retailers. org#"> <web. Location> <rdf: Alt> <rdf: li>http: //www. bn. com</rdf: li> <rdf: li>http: //www. barnesandnoble. com</rdf: li> </rdf: Alt> </web. Location> </Retailer> Barnes. And. Noble. rdf 67 <? xml version="1. 0"? > <Meeting rdf: ID="XML-Design-Pattern" xmlns: rdf="http: //www. w 3. 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> <? xml version="1. 0"? > <To. Do. List rdf: ID="Monday. Meetings" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. reminders. org#"> <activities> <rdf: Seq> <rdf: li>Meet with CEO at 10 am</rdf: li> <rdf: li>Luncheon at The Eatery</rdf: li> <rdf: li>Flight at 3 pm</rdf: li> </rdf: Seq> </activities> </To. Do. List> My. Days. Activities. rdf Design. Meeting. rdf
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 68 Example #10 Modify the following XML document so that it is also a valid RDF document: <? xml version="1. 0"? > <Catalogue xmlns="http: //www. publishing. org#" xmlns: dc="http: //pur 1. org/metadata/dublin-core#"> <Book> <dc: Title>Lateral Thinking</dc: Title> <dc: Creator>Edward de Bono</dc: Creator> <dc: Date>1973</dc: Date> <ISBN>0 -06 -099325 -2</ISBN> <dc: Publisher>Harper & Row</dc: Publisher> </Book> <dc: Title>Illusions: The Adventures of a Reluctant Messiah</dc: Title> <dc: Creator>Richard Bach</dc: Creator> <dc: Date>1977</dc: Date> <ISBN>0 -440 -34319 -4</ISBN> <dc: Publisher>Dell Publishing Co. </dc: Publisher> </Book> <dc: Title>The First and Last Freedom</dc: Title> <dc: Creator>J. Krishnamurti</dc: Creator> <dc: Date>1954</dc: Date> <ISBN>0 -06 -064831 -7</ISBN> <dc: Publisher>Harper & Row</dc: Publisher> </Book> </Catalogue> Barnes_and_Noble _Book. Catalogue. xml Note: regrettably, the Dublin Core does not conform to the RDF naming conventions. Hence, you see properties with the first letter capitalized.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 69 Things to note 1. The XML document uses two types (classes): Catalogue Book 2. All type instances are anonymous. Consequently, we cannot benefit from others, and others cannot benefit from us. Where does it make sense to give the instance an identifier? - In general, the root element should have an identifier. - There is lots of information about each book instance. Let's give each book instance an identifier (the ISBN).
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 70 Modification 1: Identifiers added <? xml version="1. 0"? > <Catalogue id="Book. Catalogue" xmlns="http: //www. publishing. org#" xmlns: dc="http: //pur 1. org/metadata/dublin-core#"> <Book id="_0 -06 -099325 -2"> <dc: Title>Lateral Thinking</dc: Title> <dc: Creator>Edward de Bono</dc: Creator> <dc: Date>1973</dc: Date> <dc: Publisher>Harper & Row</dc: Publisher> </Book> <Book id="_0 -440 -34319 -4"> <dc: Title>Illusions: The Adventures of a Reluctant Messiah</dc: Title> <dc: Creator>Richard Bach</dc: Creator> <dc: Date>1977</dc: Date> <dc: Publisher>Dell Publishing Co. </dc: Publisher> </Book> <Book id="_0 -06 -064831 -7"> <dc: Title>The First and Last Freedom</dc: Title> <dc: Creator>J. Krishnamurti</dc: Creator> <dc: Date>1954</dc: Date> <dc: Publisher>Harper & Row</dc: Publisher> </Book> </Catalogue> Why was an underscore placed in front of the ISBN? Answer: The ID datatype does not allow an identifier to begin with a digit. So, we (arbitrarily) decided to use an underscore. Barnes_and_Noble _Book. Catalogue, v 2. xml Notice that the ISBN elements were deleted and their values used as identifiers.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Modification 2: Create a property for the Book type Types (classes) contain properties. We need to wrap the Book type within a property: <? xml version="1. 0"? > <Catalogue id="Book. Catalogue" xmlns="http: //www. publishing. org#" xmlns: dc="http: //pur 1. org/metadata/dublin-core#"> <item> <Book id="_0 -06 -099325 -2"> <dc: Title>Lateral Thinking</dc: Title> <dc: Creator>Edward de Bono</dc: Creator> <dc: Date>1973</dc: Date> <dc: Publisher>Harper & Row</dc: Publisher> </Book> </item> <Book id="_0 -440 -34319 -4"> <dc: Title>Illusions: The Adventures of a Reluctant Messiah</dc: Title> <dc: Creator>Richard Bach</dc: Creator> <dc: Date>1977</dc: Date> <dc: Publisher>Dell Publishing Co. </dc: Publisher> </Book> </item> <Book id="_0 -06 -064831 -7"> <dc: Title>The First and Last Freedom</dc: Title> <dc: Creator>J. Krishnamurti</dc: Creator> <dc: Date>1954</dc: Date> <dc: Publisher>Harper & Row</dc: Publisher> </Book> </item> </Catalogue> Barnes_and_Noble _Book. Catalogue, v 3. xml 71
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. RDF Format! <? xml version="1. 0"? > <Catalogue rdf: ID="Book. Catalogue" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. publishing. org#" xmlns: dc="http: //pur 1. org/metadata/dublin-core#" xml: base="http: //www. bn. com"> <item> <Book rdf: ID="_0 -06 -099325 -2" xml: base="http: //www. publishing. org/book"> <dc: Title>Lateral Thinking</dc: Title> <dc: Creator>Edward de Bono</dc: Creator> <dc: Date>1973</dc: Date> <dc: Publisher>Harper & Row</dc: Publisher> </Book> </item> <Book rdf: ID="_0 -440 -34319 -4" xml: base="http: //www. publishing. org/book"> <dc: Title>Illusions: The Adventures of a Reluctant Messiah</dc: Title> <dc: Creator>Richard Bach</dc: Creator> <dc: Date>1977</dc: Date> <dc: Publisher>Dell Publishing Co. </dc: Publisher> </Book> </item>. . . </Catalogue> Barnes_and_Noble_Book. Catalogue. rdf 72
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 73 Dublin Core (dc: ) • The Dublin Core is a standard set of properties: Content Intellectual Property Instance Title Subject Description Language Relation Coverage Source Creator Publisher Contributor Rights Date Type Format Identifier Note: many people use these properties in their HTML today. For example: <META NAME="DC. Creator" CONTENT="John Smith">
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. rdf: parse. Type="Collection" • This may be added as an attribute of a property to indicate that the contents of the property is a list of resources. • The following slide recasts the Book. Catalogue example to use this list type. 74
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 75 <? xml version="1. 0"? > <Catalogue rdf: ID="Book. Catalogue" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. publishing. org#" xmlns: dc="http: //pur 1. org/metadata/dublin-core#" xml: base="http: //www. bn. com"> <books rdf: parse. Type="Collection"> <Book rdf: ID="_0 -06 -099325 -2" xml: base="http: //www. publishing. org/book"> <dc: Title>Lateral Thinking</dc: Title> <dc: Creator>Edward de Bono</dc: Creator> <dc: Date>1973</dc: Date> <dc: Publisher>Harper & Row</dc: Publisher> </Book> <Book rdf: ID="_0 -440 -34319 -4" xml: base="http: //www. publishing. org/book"> <dc: Title>Illusions: The Adventures of a Reluctant Messiah</dc: Title> <dc: Creator>Richard Bach</dc: Creator> <dc: Date>1977</dc: Date> <dc: Publisher>Dell Publishing Co. </dc: Publisher> </Book>. . . </books> </Catalogue> Barnes_and_Noble_Book. Catalogue. rdf Do Lab 4
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 76 Example #11 Modify the following XML document so that it is also a valid RDF document: <? xml version="1. 0"? > <Article id="Quick. Brown. Fox" xmlns="http: //www. publishing. org"> <paragraph> The quick brown <bold>fox</bold> jumped over the lazy dog. An important person once said "<quote>Now is the time for all good men to come to the aid of their country</quote>" </paragraph> </Article> The paragraph contains "mixed content". Quick. Brown. Fox. xml <? xml version="1. 0"? > <Article rdf: ID="Quick. Brown. Fox" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. publishing. org#"> <paragraph rdf: parse. Type="Literal"> The quick brown <bold>fox</bold> jumped over the lazy dog. An important person once said "<quote>Now is the time for all good men to come to the aid of their country</quote>" </paragraph> </Article> Quick. Brown. Fox. rdf: parse. Type="Literal" indicates that the content of paragraph is to be treated simply as literal XML, i. e. , tools shouldn't try to parse the content into resource/property/value triples.
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. rdf: parse. Type="Literal" • In all of the previous examples the data was structured as resource/property/value triples. • Sometimes it doesn't make sense to do such structuring – Example: with mixed content • In those cases we can simply indicate "hey, the content of this property is okay. Treat it as a literal XML string. " 77
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Dangers of rdf: parse. Type="Literal" • The advantage of structuring your XML as resource/property/value triples is enhanced interoperability. • When you use rdf: parse. Type="Literal" you lose the ability for a tool to instantly take advantage of the resource/property/value structure (since you are, by definition, saying that the data doesn't have this structure). • Lesson Learned: use rdf: parse. Type="Literal" sparingly! 78
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 79 Example 12 Modify the following XML document so that it is also a valid RDF document: XML <? xml version="1. 0"? > <River id="Yangtze" xmlns="http: //www. geodesy. org/river" length="6300 kilometers" starting. Location="western China's Qinghai-Tibet Plateau" ending. Location="East China Sea"/> Note that attributes are being used, not child elements! Yangtze. xml RDF <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#" xmlns: r="http: //www. geodesy. org/river#" r: length="6300 kilometers" r: starting. Location="western China's Qinghai-Tibet Plateau" r: ending. Location="East China Sea"/> Yangtze. rdf The RDF format allows you to use attributes as well!
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Attributes • Recall that at the very beginning of this tutorial we said that a resource has properties (attributes). Thus, a property can be represented either as a child element, or as an attribute. (Of course, a property can only be represented as an attribute if it has a literal value, not a structured value. ) 80
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 81 Equivalent! <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#"> <length>6300 kilometers</length> <starting. Location>western China's Qinghai-Tibet Plateau</starting. Location> <ending. Location>East China Sea</ending. Location> </River> <? xml version="1. 0"? > <River rdf: ID="Yangtze" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. geodesy. org/river#" xmlns: r="http: //www. geodesy. org/river#" r: length="6300 kilometers" r: starting. Location="western China's Qinghai-Tibet Plateau" r: ending. Location="East China Sea"/> Do Lab 5
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Example #13 Modify the following XML document so that it is also a valid RDF document: <? xml version="1. 0"? > <Resume xmlns="http: //www. resume. org#"> <Person xmlns="http: //www. person. org#"> <name>John Smith</name> <phone>555 -1212</phone> <email>abc@def. com</email> </Person> <experience> <Job> <start. Date>1995 -01 -01</start. Date> <end. Date>1999 -01 -01</end. Date> <title>researcher</title> <employer>Some Corp</employer> <employer. Homepage>http: //www. company. org</employer. Homepage> <description>Cool stuff</description> </Job> </experience> <skills> <Skill name="Oracle" yrs="13"/> <Skill name="Java" yrs="3"/> </skills> <education> <Degree type="BS" school="RPI" year="1987"/> </education> </Resume> 82
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. <? xml version="1. 0"? > <Resume rdf: ID="JSmith-2003" xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns="http: //www. resume. org#" xml: base="http: //www. jsmith. com/resume"> <about> <Person xmlns="http: //www. person. org#"> <name>John Smith</name> <phone>555 -1212</phone> <email>abc@def. com</email> </Person> </about> <experience rdf: parse. Type="Collection"> <Job> <start. Date>1995 -01 -01</start. Date> <end. Date>1999 -01 -01</end. Date> <title>researcher</title> <employer> <Company xmlns="http: //www. company. org#"> <name>Some Corp</name> <homepage>http: //www. company. org</homepage> </Company> </employer> <description>Cool stuff</description> </Job> </experience> 83 <skills rdf: parse. Type="Collection"> <Skill> <name>Oracle</name> <years. Experience>13</years. Experience> </Skill> <name>Java</name> <years. Experience>3 </years. Experience> </Skill> </skills> <education rdf: parse. Type="Collection"> <Degree xmlns="http: //www. schools. com#"> <type>BS</type> <school>RPI</school> <graduation. Year>1987</graduation. Year> </Degree> </education> </Resume>
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. Conclusion • In this tutorial we demonstrated that, with oftentimes slight modifications, "traditional XML" documents can be made RDF-compliant. • We recommend using the RDF format for all your XML documents. • We feel that the advantages accrued by formatting your XML far outweigh any possible disadvantages (having to structure your XML in a specific format and having to learn a new vocabulary) 84
Roger L. Costello, David B. Jacobs. © 2003 The MITRE Corporation. 85 Related Articles "Make Your XML RDF-Friendly" by Bob Du. Charme, John Cowan http: //www. xml. com/pub/a/2002/10/30/rdf-friendly. html
- Slides: 85