.opennet Technologies XML Examples: RDF & RSS Fall Semester 2001 MW 5:00 pm - 6:20 pm CENTRAL (not Indiana) Time Geoffrey Fox and.
Download ReportTranscript .opennet Technologies XML Examples: RDF & RSS Fall Semester 2001 MW 5:00 pm - 6:20 pm CENTRAL (not Indiana) Time Geoffrey Fox and.
.opennet Technologies XML Examples: RDF & RSS Fall Semester 2001 MW 5:00 pm - 6:20 pm CENTRAL (not Indiana) Time Geoffrey Fox and Bryan Carpenter PTLIU Laboratory for Community Grids Computer Science, Informatics, Physics Indiana University Bloomington IN 47404 [email protected] 11/6/2015 xmlexamplesrdffall01 1 Basic Principles • We describe the use of XML to specify Metadata – data about data • Metadata can also be thought of as “overall properties” of an entity • Example: Author is part of Metadata for Books or Computer Programs • Example: Capacity of Football stadium could be key part of metadata for universities • Here we describe a general framework -- RDF (Resource Description Framework) for making assertions about metadata • We previously described a particular example – DC (Dublin Core) of metadata about bibliographic material – books, web pages etc. 11/6/2015 xmlexamplesrdffall01 2 References on RDF • There are two W3C documents about RDF which are quite hard to read • RDF Model and Syntax: http://www.w3.org/TR/REC-rdf-syntax/ – Defines basic ideas for any metadata vocabulary • RDF Schema http://www.w3.org/TR/2000/CR-rdf-schema20000327/ – Describes general structure of a metadata vocabulary • One of the earliest users of RDF was Netscape in their Mozilla (Netscape 6) activity http://www.mozilla.org/rdf/doc/ where they use RDF to describe user specific information about browser – actually this describes trees in areas of bookmarks and email as RDF naturally defines general graphs – I found this short discussion an interesting comment on a non metadata application of RDF 11/6/2015 xmlexamplesrdffall01 3 RDF Statements Predicate Subject Object • The essence of RDF is a statement which has a subject and predicate and an object • The “subject” has the property “predicate” with value “object” • The Web Page has the title “RDF Model and Syntax” • Mary had a husband called John • Statements can specify metadata but more generally any facts expressible in this way • One can associate multiple objects with a subject and so build up a general node of a tree with parent as subject and objects as children. Thus RDF can define a general tree fragment as shown on next foil 11/6/2015 xmlexamplesrdffall01 4 RDF Tree Fragment Class Same Predicate: Student General Subject Agatha Henry Same or Different Predicates Objec t Objec t email Objec t Fred@jim Different Predicates Fred Nick name Freddie grade B- Specific Objec t 11/6/2015 Objec t Objec t xmlexamplesrdffall01 5 RDF Building Concepts • Resource: Any identifiable object – must have a URI of style begin://rootlabel/nextlabel/…./lastlabel – This URI could be a Web address but anything of “approved format” is allowed – each person could start their own personal://Country/SSNorEquivalent/Classify/How/you/want/item – URI syntax is http://www.isi.edu/in-notes/rfc2396.txt • Property: A special resource of “type” property • Object: Either a resource or a literal – a literal is something like a text or even XML string. • Example: take a case with Property as Name. This Name could have a URI derived from the URI of the Dublin Core Schema and Name’s definition therein. So Name is indeed a Resource • Then the object could either be literal “Geoffrey Fox” or resource given by my home page http://www.newnpac.org/users/fox/homepage/ 11/6/2015 xmlexamplesrdffall01 6 What is a URL URN or URI ? • http://www.w3.org/Addressing/ 11/6/2015 xmlexamplesrdffall01 7 URI • PURL’s Persistent URL’s at http://purl.oclc.org/ are URN’s that are also URL’s gotten by using an intermediate directory that maps permanent name to ephemeral URL’s • If you use abc://d/e/g … , then MUST be a hierarchical labeling and familiar relative addresses are allowed – ../differentparent goes up one level – // is always root • Should get in habit of using URI’s that are persistent labels as these are key to registry and discovery systems • http://www.w3.org/Addressing/schemes.html lists “URI Schemes” such as afs (Andrew File system), fax, file, ftp, gopher, http, imap, ldap, news, nfs, nntp, pop, rtsp, sip, tel, telnet, wais, z39.50r, z39.50s (z39.50 is databasesearch and retrieval protocol) • I will use my own URI’s (petokc:// …) for work I am doing with ERDC 11/6/2015 xmlexamplesrdffall01 8 An Example of RDF and Dublin Core • <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/metadata/dublin_core#"> • <rdf:Description about="http://www.dlib.org"> • <dc:Title>D-Lib Program - Research in Digital Libraries</dc:Title> <dc:Description>The D-Lib program supports the community of people with research interests in digital libraries and electronic publishing. </dc:Description> <dc:Publisher>Corporation For National Research Initiatives</dc:Publisher> <dc:Date>1995-01-07</dc:Date> • <dc:Subject> – <rdf:Bag> <rdf:li>Research; statistical methods</rdf:li> <rdf:li>Education, research, related topics</rdf:li> <rdf:li>Library use Studies</rdf:li> </rdf:Bag> • </dc:Subject> <dc:Type>World Wide Web Home Page</dc:Type> • <dc:Format>text/html</dc:Format> • <dc:Language>en</dc:Language> • </rdf:Description> </rdf:RDF> 11/6/2015 xmlexamplesrdffall01 9 Comments on Example • We define the RDF and DC (Dublin Core) Namespaces • We define resource http://www.dlib.org with <rdf:Description about=“. We want to add DC metadata describing this web page • We see Dublin Core metadata Title, Description, Publisher, Date, Subject, Type, format, Language • We see use of RDF Bag syntax to specify 3 separate “subject” values • Note that RDF provides the overall framework with the description tag mapping a resource (http://www.dlib.org) to a set of properties • The properties are defined in a completely different namespace – the Dublin Core • RDF provides useful expressivity with a “collection” syntax of which bag (unordered collection) is one example 11/6/2015 xmlexamplesrdffall01 10 RDF Basics • Now we go back and define basic RDF syntax in more detail • Consider the simple statement: • Ora Lassila is the creator of the resource http://www.w3.org/Home/Lassila. • Or “http://www.w3.org/Home/Lassila has creator Ora Lassila”. • Or in general "<subject> HAS <predicate> <object>". • Specified by <rdf:RDF> <rdf:Description about="http://www.w3.org/Home/Lassila"> <s:Creator>Ora Lassila</s:Creator> </rdf:Description> </rdf:RDF> Subject Resource 11/6/2015 Predicate(property) xmlexamplesrdffall01 Object 11 Anonymous resources • We may wish to specify multiple properties which can do with a diagram like that here and with typical RDF syntax • <rdf:RDF> <rdf:Description about="http://www.w3.org/Home/Lassila"> <s:Creator> <v:Name>Ora Lassila</v:Name> <v:Email>[email protected]</v:Email> • </s:Creator> </rdf:Description> </rdf:RDF> Anonymous Resource 11/6/2015 xmlexamplesrdffall01 12 Tree-like Syntax • <rdf:RDF> <rdf:Description about="http://www.w3.org/Home/Lassila"> <s:Creator> <rdf:Description about="http://www.w3.org/staffId/85740"> <v:Name>Ora Lassila</v:Name> <v:Email>[email protected]</v:Email> </rdf:Description> </s:Creator> </rdf:Description> </rdf:RDF> • Here We give the anonymous resource a name such as “employee 85740” with a URI pointing to “employee database entry” 11/6/2015 xmlexamplesrdffall01 13 Abbreviations • We can put the predicate=“object” specification as an attribute. For our simplest case this gives: • <rdf:RDF> <rdf:Description about="http://www.w3.org/Home/Lassila" s:Creator="Ora Lassila" /> </rdf:RDF> • We can abbreviate our last example: • <rdf:RDF> <rdf:Description about="http://www.w3.org/Home/Lassila"> <s:Creator rdf:resource="http://www.w3.org/staffId/85740" v:Name="Ora Lassila" v:Email="[email protected]" /> </rdf:Description> </rdf:RDF> • These abbreviations both shorten the text and hide XML tags as attributes. This means that undesirable actions/errors by browsers that don’t know various namespaces are avoided 11/6/2015 xmlexamplesrdffall01 14 Example of a Bag I • We already have seen the Bag syntax illustrated. There are three collections in RDF: Bag,Seq and Alt. Lets look at Bag again • The students in course 6.001 are Amy, Tim, John, Mary, and Sue. • This statement is represented graphically as shown. • One can represent it either using a syntax like HTML unordered lists or using explicit member references such as rdf:_1=" Amy” 11/6/2015 xmlexamplesrdffall01 15 Bag Collection II • This is most directly written • <rdf:RDF> <rdf:Description about="http://mycollege.edu/courses/6.001"> • <s:students> <rdf:Bag> • <rdf:li resource="http://mycollege.edu/students/Amy"/> • <rdf:li resource="http://mycollege.edu/students/Tim"/> • <rdf:li resource="http://mycollege.edu/students/John"/> • <rdf:li resource="http://mycollege.edu/students/Mary"/> • <rdf:li resource="http://mycollege.edu/students/Sue"/> • </rdf:Bag> </s:students> • </rdf:Description> </rdf:RDF> 11/6/2015 xmlexamplesrdffall01 16 Alternative Bag Syntax • <rdf:RDF> <rdf:Description about="http://mycollege.edu/courses/6.001"> • <s:students rdf:type=“http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag” • rdf:_1=“http://mycollege.edu/students/Amy” • rdf:_2="http://mycollege.edu/students/Tim“ • rdf:_3="http://mycollege.edu/students/John" • rdf:_4="http://mycollege.edu/students/Mary" • rdf:_5="http://mycollege.edu/students/Sue" • /> • </rdf:Description> </rdf:RDF> 11/6/2015 xmlexamplesrdffall01 17 Alternative Bag Syntax • <rdf:RDF> <rdf:Description about="http://mycollege.edu/courses/6.001"> • <s:students rdf:type=“http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag” • rdf:_1=“http://mycollege.edu/students/Amy” • rdf:_2="http://mycollege.edu/students/Tim“ • rdf:_3="http://mycollege.edu/students/John" • rdf:_4="http://mycollege.edu/students/Mary" • rdf:_5="http://mycollege.edu/students/Sue" • /> • </rdf:Description> </rdf:RDF> 11/6/2015 xmlexamplesrdffall01 18 The three basic Collections • Bag: (rdf:Bag) An unordered list of resources or literals. Bags are used to declare that a property has multiple values and that there is no significance to the order in which the values are given. Bag might be used to give a list of part numbers where the order of processing the parts does not matter. Duplicate values are permitted. • Sequence: (rdf:Seq) An ordered list of resources or literals. Sequence is used to declare that a property has multiple values and that the order of the values is significant. Sequence might be used, for example, to preserve an alphabetical ordering of values. Duplicate values are permitted. • Alternative: (rdf:Alt) A list of resources or literals that represent alternatives for the (single) value of a property. Alternative might be used to provide alternative language translations for the title of a work, or to provide a list of Internet mirror sites at which a resource might be found. An application using a property whose value is an Alternative collection is aware that it can choose any one of the items in the list as appropriate. Alt must have at least one member; the first member of Alt is default object. 11/6/2015 xmlexamplesrdffall01 19 about and aboutEach I • Let us define a collection with local name pages • <rdf:Bag ID="pages“ > <rdf:li resource="http://foo.org/foo.html" /> <rdf:li resource="http://bar.org/bar.html" /> </rdf:Bag> • Then we can define the creator of the Collection by: • <rdf:Description about="#pages"> <s:Creator>Ora Lassila</s:Creator> </rdf:Description> • Now this does not say anything about the creator of the individual resources in the bag • For this we need aboutEach 11/6/2015 xmlexamplesrdffall01 20 about and aboutEach II • <rdf:Description aboutEach="#pages"> <s:Creator>Ora Lassila</s:Creator> </rdf:Description> • Is equivalent to two separate “about” descriptions – one for each member of the bag • <rdf:Description about="http://foo.org/foo.html"> <s:Creator>Ora Lassila</s:Creator> </rdf:Description> <rdf:Description about="http://bar.org/bar.html"> <s:Creator>Ora Lassila</s:Creator> </rdf:Description> 11/6/2015 xmlexamplesrdffall01 21 aboutEachPrefix I • if the two resources http://foo.org/doc/page1 and http://foo.org/doc/page2 exist then: • <rdf:Description aboutEachPrefix="http://foo.org/doc"> <s:Copyright>© 1998, The Foo Organization</s:Copyright> </rdf:Description> • Says that these two pages have the same copyright information – If billions of documents in this collection (i.e. with this prefix, then all are given this copyright metadata) • For two documents we can define this information in other ways given on next page 11/6/2015 xmlexamplesrdffall01 22 aboutEachPrefix II <rdf:Description about="http://foo.org/doc/page1"> <s:Copyright>© 1998, The Foo Organization</s:Copyright> </rdf:Description> <rdf:Description about="http://foo.org/doc/page2"> <s:Copyright>© 1998, The Foo Organization</s:Copyright> </rdf:Description> Or you could use Bag notation <rdf:Description aboutEach=“#docpages"> <s:Copyright>© 1998, The Foo Organization</s:Copyright> </rdf:Description> <rdf:Bag ID="docpages"> – <rdf:li resource="http://foo.org/doc/page1"/> – <rdf:li resource="http://foo.org/doc/page2"/> • </rdf:Bag> • • • • • • • • • • • 11/6/2015 xmlexamplesrdffall01 23 rdf:value • <RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:n="http://www.nist.gov/units/"> <Description about="John_Smith"> <n:weight rdf:parseType="Resource"> <rdf:value> 200 </rdf:value> <n:units rdf:resource="http://www.nist.gov/units/Pounds"/> </n:weight> </Description> </RDF> • <rdf:value is primary value of weight • This syntax allows directly non-binary relations 11/6/2015 xmlexamplesrdffall01 24 <rdf:value <rdf:parseType <dcq Example • <rdf:Description about=“ http://www.dlib.org/dlib/may98/05contents.html"> • ……………………. • <dc:Contributor rdf:parseType="Resource"> <dcq:AgentType rdf:resource="http://purl.org/metadata/dublin_core_qualifiers#E ditor"/> • <rdf:value>Amy Friedlander</rdf:value> </dc:Contributor> • <dc:Relation rdf:parseType="Resource"> <dcq:RelationType rdf:resource="http://purl.org/metadata/dublin_core_qualifiers#Is PartOf"/> <rdf:value resource=“http://www.dlib.org” /> </dc:Relation> • </rdf:Description> 11/6/2015 xmlexamplesrdffall01 25 <rdf:value <rdf:parseType <dcq • <tag rdf:parseType=“.” >Contents</tag> • Attribute rdf:parseType can either be “Literal” or “Resource” • If “Resource”, then Contents of this tag must “match the syntax of a rdf:description tag” and define a resource • If no XML tags in contents or rdf:parseType=“Literal”, then RDF processor will NOT process Contents • In previous page, we use rdf:value to specify a principal value and a qualification (dcq namespace for Dublin Core Qualifier) RelationType Relation Anonymous Resource rdf:value 11/6/2015 xmlexamplesrdffall01 26 rdf:parseType=“Literal” • Here is an example: • <dc:Title rdf:parseType="Literal“ > Ramifications of <apply> <power/> <apply> <plus/> <ci>a</ci> <ci>b</ci> </apply> <cn>2</cn> </apply> to World Peace </dc:Title> • Here the MathML text is NOT interpreted by RDF but considered as an XML string defining this resource 11/6/2015 xmlexamplesrdffall01 27 Mozilla RDF Tags http://dmoz.org/rdf/tags.html 11/6/2015 xmlexamplesrdffall01 28 Mozilla Use of RDF This is edited to be small. See web page http://dmoz.org/rdf/structure.example.txt 11/6/2015 xmlexamplesrdffall01 29 Syndication: RDF to define Web Pages • As discussed, RDF was originally designed to specify information (meta-data) about web pages so that one could search for pages more effectively • We can use it as basis of Syndication which can be defined as making data available online for retrieval and further transmission, aggregation, or online publication. • This is equivalent to defining contents of web pages in terms of links, text, images as well other issues such as rights and authorship. • The PET OKC (Online Knowledge Center) is designed to supported as a “syndication service” • There are several interesting syndication systems which are all XML based 11/6/2015 xmlexamplesrdffall01 30 Examples of Information Nugget Streams I • New York Times shows a page full of nuggets which point to more detailed descriptions 11/6/2015 xmlexamplesrdffall01 31 Examples of Information Nugget Streams II • The nuggets can be smaller and can include adverts • Syndication systems define nuggets including link to more detailed information 11/6/2015 xmlexamplesrdffall01 32 Syndication Systems • RSS version 0.91 Rich (originally RDF) Site Summary was originally developed by Netscape as a channel description framework / content-gathering mechanism for their My Netscape Network (MNN at http://my.netscape.com) http://my.netscape.com/publish/formats/rss-spec-0.91.html • RSS version 1 RDF Site Summary restores original RDF support and develops a basic framework which has RSS RDF and application dependent Schemas http://groups.yahoo.com/group/rss-dev/files/specification.html RSS feeds carry an array of content types: news headlines, discussion forums, software announcements, and various bits of specialized data (such as homes for sale, sports scores, Chemistry, PET etc. which would have their own Schema). • Open Content Syndication OCS http://internetalchemy.org/ocs/index.html is similar to RSS version 1 • ICE Information Content and Exchange http://www.icestandard.org/ is more complicated 11/6/2015 xmlexamplesrdffall01 33 The OKC Information Channels FMS/C4I IMT SIP ET -----CCM CEA CEN CDLT RSS Streams Integrated by PET Online Knowledge Center OKC HPCMP Streams delivered by HTTP (forms) or SMTP (mail) using SOAP message format 11/6/2015 xmlexamplesrdffall01 CFD CSM OKC EOTC -----EQM CWO CE ------JSU IU ERDC Army ……. 34 ICE’s Claim to Fame • ICE is intended to support the full range of content syndication. It has a number of commercial implementations, generally targeted at businesses that wish to distribute or aggregate large volumes of content with numerous business partners. Thus, it offers a range of options including: – delivery of arbitrary content types, including web pages – support of both push and pull delivery of content – access control and customization of content – Both "full update" and "incremental update" supported, with atomicity of updates, recovery mechanisms for error conditions, etc. – content delivered in-line or by reference – confirmation of delivery – auditing of ICE operations – rich scheduling of ICE delivery – meta-data relating to intellectual property, usage rights, copyright, etc. – automated negotiation of delivery and other parameters – extensible – syndication discovery protocol 11/6/2015 xmlexamplesrdffall01 35 RSS Version 1 Example I • <?xml version="1.0"?> • <rdf:RDF • xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" • xmlns="http://purl.org/rss/1.0/" > • • • • • • • • <channel rdf:about="http://www.xml.com/xml/news.rss"> <title> XML.com </title> <link> http://xml.com/pub </link> <description> XML.com features a rich mix of information and services for the XML community. </description> <image rdf:resource="http://xml.com/universal/images/xml_tiny.gif" /> 11/6/2015 xmlexamplesrdffall01 36 • • • • • • • • • • • • • RSS Version 1 Example II <items> <rdf:Seq> <rdf:li resource="http://xml.com/pub/2000/08/09/xslt/xslt.html" /> <rdf:li resource="http://xml.com/pub/2000/08/09/rdfdb/index.html" /> </rdf:Seq> </items> </channel> <image rdf:about="http://xml.com/universal/images/xml_tiny.gif"> <title> XML.com </title> <link> http://www.xml.com </link> <url> http://xml.com/universal/images/xml_tiny.gif </url> </image> 11/6/2015 xmlexamplesrdffall01 37 RSS Version 1 Example III • <item rdf:about="http://xml.com/pub/2000/08/09/xslt/xslt.html"> • <title> Processing Inclusions with XSLT </title> • <link> http://xml.com/pub/2000/08/09/xslt/xslt.html </link> • <description> • Processing document inclusions with general XML tools can be • problematic. This article proposes a way of preserving inclusion • information through SAX-based processing. • </description> • </item> • <item rdf:about="http://xml.com/pub/2000/08/09/rdfdb/index.html"> • <title> Putting RDF to Work </title> • <link> http://xml.com/pub/2000/08/09/rdfdb/index.html </link> • <description> • Tool and API support for the Resource Description Framework • is slowly coming of age. Edd Dumbill takes a look at RDFDB, • one of the most exciting new RDF toolkits. • </description> • </item> • </rdf:RDF> 11/6/2015 xmlexamplesrdffall01 38 RSS Basic Structure • • • • • • • • • • • • • RSS has a simple set of basic elements: There is RDF itself plus • <item> <channel> • <title> <title> • <link> <link> • <description> <description> • <textinput> <image> • <title> <items> • <description> <textinput> • <name> <image> • <link> <title> <url> <link> 11/6/2015 xmlexamplesrdffall01 39 RSS Modules • RSS Modules correspond to application specific extensions to basic capabilities. There are three modules “shipped” with current RSS (actually two shipped and one more approved) • Dublin Core Syndication Content • Here are others proposed 11/6/2015 xmlexamplesrdffall01 40 Syndication Module in RSS How often to update page 11/6/2015 xmlexamplesrdffall01 41 Dublin Core, Company, TextInput Modules 11/6/2015 xmlexamplesrdffall01 42 Content Module in RSS 11/6/2015 xmlexamplesrdffall01 43 Using RSS • If you are a news provider: BBC CNN AP Reuters, XYZ newsgroup, HPCwire, personal email archive etc. – You make a list of news nuggets in RSS providing an “abstract” in title/description and link for further data – This is a channel • If you a portal manager: PET OKC, New York Times, Yahoo etc. you use one of many software packages (we will use Jetspeed http://jakarta.apache.org/jetspeed/site/psml.html) to read RSS file (with ongoing updates) and provide digest with possible link to further information – There is no special agreement as to way to encode list of channels – http://www.newsisfree.com/HPE/xml/servicelist.rss gives 1725 channels (20 November 2001) in rssfeeds XML syntax (see Class Web Site (http://aspen.ucs.indiana.edu/ptliu/rssexamples/servicelist.rss) has copy of this) 11/6/2015 xmlexamplesrdffall01 44 Example of Syndication Site Channel RSS Entry 11/6/2015 xmlexamplesrdffall01 45 RSSFeeds Example • Each channel is a news feed • This is a modification of RSS extending channel element 11/6/2015 xmlexamplesrdffall01 46 Useful RSS usage Links • • • • • • Syndication Sites are illustrated by: http://10.am/ http://www.newsisfree.com/ http://4xt.org/news/ [rss file: http://4xt.org/news/general.rss10 ] http://www.oreillynet.com/rss/ http://aspen.ucs.indiana.edu/ptliu/rssexamples/news4xt.htm was generated from RSS File http://aspen.ucs.indiana.edu/ptliu/rssexamples/general.rss10 • http://aspen.ucs.indiana.edu/ptliu/rssexamples/bluetoothrss.xml is a smaller RSS file driving a Bluetooth site 11/6/2015 xmlexamplesrdffall01 47 A small RSS News Stream • Note HTML embedded in RSS which is version 0.91 11/6/2015 xmlexamplesrdffall01 48 RDF Statements I • There is a formal way of looking at RDF statements which break it up into (subject,predicate,object) triple – This allows (as on next foil) one to maker statements about statements • rdf:Statement - This class corresponds to the set called the 'Statement ‘ in the formal model for RDF. • rdf:subject - This corresponds to the property called the 'subject' in the formal model for RDF. – Its rdfs:domain is rdf:Statement and rdfs:range is rdfs:Resource. – This is used to specify the resource described by a reified statement. • rdf:predicate - This corresponds to the property called the 'predicate' in the formal model for RDF. – Its rdfs:domain is rdf:Statement and rdfs:range is rdf:Property. – This is used to identify the property used in the modeled statement. • rdf:object - This corresponds to the property called the 'object' in the formal model for RDF. – Its rdfs:domain is rdf:Statement. – This is used to identify the property value in the modeled statement. 11/6/2015 xmlexamplesrdffall01 49 RDF Statements II • <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntaxns#" xmlns:a="http://description.org/schema/"> • <rdf:Description> • <rdf:subject resource="http://www.w3.org/Home/Lassila" /> • <rdf:predicate resource="http://description.org/schema/Creator" /> • <rdf:object>Ora Lassila</rdf:object> • <rdf:type resource="http://www.w3.org/1999/02/22-rdf-syntaxns#Statement" /> • <a:attributedTo>Ralph Swick</a:attributedTo> </rdf:Description> • </rdf:RDF> • Here we attribute assertion (statement) to Raplh Swick 11/6/2015 xmlexamplesrdffall01 50 ID and bagID in RDF • If another Description or property value needs to refer to the in-line resource it will use the value of the ID of that resource in its own about attribute. – The ID attribute signals the creation of a new resource and the about attribute refers to an existing resource; therefore either ID or about may be specified on Description but not both together in the same element. – The values for each ID attribute must not appear in more than one ID attribute within a single document. • There is also bagID used to label container containing formal RDF Statements • We can write: <rdf:RDF> <rdf:Description about="http://www.w3.org/Home/Lassila" bagID="D_001"> <s:Creator>Ora Lassila</s:Creator> <s:Title>Ora's Home Page</s:Title> </rdf:Description> </rdf:RDF> • And then add assertion about attribution via <rdf:Description aboutEach="#D_001"> <a:attributedTo>Ralph Swick</a:attributedTo> </rdf:Description> 11/6/2015 xmlexamplesrdffall01 51 RDF Schema • This sets up a framework like the Java (and other languages) to define classes and other features of Resources that enable one to talk about Resources as Instances of classes • Below rounded rectangles represents a class of resources • The outermost rectangle is the set of all resources i.e. all “objects” • Classes are themselves resources and 5 examples are given corresponding to four rounded rectangles and literals (which are not resources even though the literal class is a resource Literals are objects 11/6/2015 xmlexamplesrdffall01 52 RDF Schema This shows a Motor Vehicle Metadata with Sub Classes 11/6/2015 xmlexamplesrdffall01 53 Motor Vehicle Class Hierarchy • This picture shows the RDF graph corresponding to previous example 11/6/2015 xmlexamplesrdffall01 54 RDF Schema Core Properties • rdf:type – This indicates that a resource is a member of a class, and thus has all the characteristics that are to be expected of a member of that class. – When a resource has an rdf:type property whose value is some specific class, we say that the resource is an instance of the specified class. – The value of an rdf:type property for some resource is another resource which must be an instance of rdfs:Class. – The resource known as rdfs:Class is itself a resource of rdf:type rdfs:Class. – Individual classes (for example, 'Dog') will always have an rdf:type property whose value is rdfs:Class (or some subclass of rdfs:Class, as described in section 2.3.2). A resource may be an instance of more than one class. • rdfs:subClassOf – This property specifies a subset/superset relation between classes. The rdfs:subClassOf property is transitive. – If class A is a subclass of some broader class B, and B is a subclass of C, then A is also implicitly a subclass of C. Consequently, resources that are instances of class A will also be instances of C, since A is a sub-set of both B and C. – Only instances of rdfs:Class can have the rdfs:subClassOf property and the property value is always of rdf:type rdfs:Class. – A class may be a subclass of more than one class. 11/6/2015 xmlexamplesrdffall01 55 RDF Core Classes • RDF Schema is http://www.w3.org/TR/2000/CR-rdf-schema-20000327/ • There are three core classes • rdfs:Resource – All things being described by RDF expressions are called resources, and are considered to be instances of the class rdfs:Resource. • rdf:Property represents the subset of RDF resources that are properties • rdfs:Class – This corresponds to the generic concept of a Type or Category, similar to the notion of a Class in object-oriented programming languages such as Java. When a schema defines a new class, the resource representing that class must have an rdf:type property whose value is the resource rdfs:Class. – RDF classes can be defined to represent almost anything, such as Web pages, people, document types, databases or abstract concepts. 11/6/2015 xmlexamplesrdffall01 56 rdfs:subPropertyOf • The property rdfs:subPropertyOf is an instance of rdf:Property that is used to specify that one property is a specialization of another. – A property may be a specialization of zero, one or more properties. – If some property P2 is a subPropertyOf another more general property P1, and if a resource A has a P2 property with a value B, this implies that the resource A also has a P1 property with value B. • A property can never be declared to be a subproperty of itself, nor of any of its own subproperties • Here is an example with biologicalFather as a subpropertyOf biologicalParent • Note use of ID 11/6/2015 xmlexamplesrdffall01 57 rdfs:seeAlso and rdfs:isDefinedBy • rdfs:seeAlso – The property rdfs:seeAlso specifies a resource that might provide additional information about the subject resource. – This property may be specialized using rdfs:subPropertyOf to more precisely indicate the nature of the information the object resource has about the subject resource. – The object and the subject resources are constrained only to be instances of the class rdfs:Resource. • rdfs:isDefinedBy – The property rdfs:isDefinedBy is a subproperty of rdfs:seeAlso, and indicates the resource defining the subject resource. – As with rdf:seeAlso, this property can be applied to any instance of rdfs:Resource and may have as its value any rdfs:Resource. 11/6/2015 xmlexamplesrdffall01 58 rdfs Constraints • rdfs:ConstraintResource – This resource defines a subclass of rdfs:Resource whose instances are RDF schema constructs involved in the expression of constraints. – The purpose of this class is to provide a mechanism that allows RDF processors to assess their ability to use the constraint information associated with an RDF model. – Since this specification does not provide a mechanism for the dynamic discovery of new forms of constraint, an RDF Schema 1.0 processor encountering previously unknown instances of rdfs:ConstraintResource can be sure that it is unqualified to determine the meaning of those constraints. • rdfs:ConstraintProperty – This resource defines a subclass of rdf:Property, all of whose instances are properties used to specify constraints. – This class is a subclass of rdfs:ConstraintResource and corresponds to the subset of that class representing properties. – Both rdfs:domain and rdfs:range are instances of rdfs:ConstraintProperty. 11/6/2015 xmlexamplesrdffall01 59 Rdf:range rdfs:domain • rdfs:range – An instance of ConstraintProperty that is used to indicate the class(es) that the values of a property must be members of. – The value of a range property is always a Class. – Range constraints are only applied to properties. – A property can have at most one range property. – It is possible for it to have no range, in which case the class of the property value is unconstrained. • rdfs:domain – An instance of ConstraintProperty that is used to indicate the class(es) on whose members a property can be used. – A property may have zero, one, or more than one class as its domain. – If there is no domain property, the property may be used with any resource. If there is exactly one domain property, it may only be used on instances of that class (which is the value of the domain property). – If there is more than one domain property, the constrained property can be used with instances of any of the classes (that are values of those domain properties). 11/6/2015 xmlexamplesrdffall01 60 Example of rdfs:domain and rdfs:range • Note domain tells you about “subject” – resource being described by a particular property • range tells you about allowed values of property • “registeredTo” applies to MotorVehicle’s and must be a Person 11/6/2015 xmlexamplesrdffall01 61 Useful Base rdf rdfs Properties and Classes • rdfs:comment - This property is used to provide a human-readable description of a resource. • rdfs:label - This property is used to provide a human-readable version of a resource name. • rdfs:Literal - This class corresponds to the set called the 'Literals' in the formal model for RDF. – Atomic values such as textual strings are examples of RDF literals. • rdfs:Container - This class describes rdf:Bag rdf:Seq rdf:Alt. – It is an instance of rdfs:Class and rdfs:subClassOf of rdfs:Resource. • rdf:Bag - This is the class called 'Bag' in the formal model for RDF. – It is an instance of rdfs:Class and rdfs:subClassOf rdfs:Container. • rdf:Seq - This is the class called 'Sequence' in the formal model for RDF. – It is an instance of rdfs:Class and rdfs:subClassOf rdfs:Container. • rdf:Alt - This is the class called 'Alternative' in the formal model for RDF. – It is an instance of rdfs:Class and rdfs:subClassOf rdfs:Container. • rdfs:ContainerMembershipProperty - This class has as members the properties _1, _2, _3 ... used to indicate container membership. – This is a rdfs:subClassOf rdf:Property. • rdf:value - This property corresponds to the 'value' property of an rdf:object. 11/6/2015 xmlexamplesrdffall01 62 Example of a Person RDFS Schema I 11/6/2015 xmlexamplesrdffall01 63 Example of a Person RDFS Schema II • In previous foil, Person is a class with a corresponding human-readable description of "The class of people". • Animal is a class presumed to be defined in another schema. All persons are animals, so we declare that Person is a subclass of Animal. • A Person may have an age property. The value of age is an integer. • A Person may also have an ssn ("Social Security Number") property. The value of ssn is an integer. • A Person's marital status is one of {Single, Married, Divorced, Widowed}. – This is achieved through use of the rdfs:range constraint: we define both a maritalStatus property and a class MaritalStatus (adopting the convention of using lower case letters to begin the names of properties, and capitals for classes). – We then use rdfs:range to state that a maritalStatus property only 'makes sense' when it has a value which is an instance of the class MaritalStatus. – The schema then defines a number of instances of this class. – Whether resources declared to be of type MaritalStatus in another graph are trusted is an application level decision. 11/6/2015 xmlexamplesrdffall01 64 rdfs Example • • • • • 11/6/2015 xmlexamplesrdffall01 This is an RDF vocabulary for use with searchable Internet services. SearchQuery is declared to be a class. Every SearchQuery can have both a queryString whose value is an rdfs:Literal and a queryService whose value is a SearchService. A SearchService is a subclass of InternetService (which is defined elsewhere). A SearchQuery has some number of result properties (whose value is SearchResult). Each SearchResult has a title (value is a rdfs:Literal), a rating and of course, the page itself. 65