- XML Reference Guide
- Overview
- What Is XML?
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Table of Contents
- The Document Object Model
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- DOM and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- Implementations
- DOM and JavaScript
- Using a Repeater
- Repeaters and XML
- Repeater Resources
- DOM and .NET
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Downloads
- DOM and C++
- DOM and C++ Resources
- DOM and Perl
- DOM and Perl Resources
- DOM and PHP
- DOM and PHP Resources
- DOM Level 3
- DOM Level 3 Core
- DOM Level 3 Load and Save
- DOM Level 3 XPath
- DOM Level 3 Validation
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Implementations
- The Simple API for XML (SAX)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- SAX and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- SAX and .NET
- Informit Articles and Sample Chapters
- SAX and Perl
- SAX and Perl Resources
- SAX and PHP
- SAX and PHP Resources
- Validation
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Document Type Definitions (DTDs)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XML Schemas
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- RELAX NG
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Schematron
- Official Documentation and Implementations
- Validation in Applications
- Informit Articles and Sample Chapters
- Books and e-Books
- XSL Transformations (XSLT)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XSLT in Java
- Java in XSLT Resources
- XSLT and RSS in .NET
- XSLT and RSS in .NET Resources
- XSL-FO
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XPath
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XML Base
- Informit Articles and Sample Chapters
- Official Documentation
- XHTML
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XHTML 2.0
- Documentation
- Cascading Style Sheets
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XUL
- XUL References
- XML Events
- XML Events Resources
- XML Data Binding
- Informit Articles and Sample Chapters
- Books and e-Books
- Specifications
- Implementations
- XML and Databases
- Informit Articles and Sample Chapters
- Books and e-Books
- Online Resources
- Official Documentation
- SQL Server and FOR XML
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Implementations
- Service Oriented Architecture
- Web Services
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Creating a Perl Web Service Client
- SOAP::Lite
- Amazon Web Services
- Creating the Movable Type Plug-in
- Perl, Amazon, and Movable Type Resources
- Apache Axis2
- REST
- REST Resources
- SOAP
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- SOAP and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- WSDL
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- UDDI
- UDDI Resources
- XML-RPC
- XML-RPC in PHP
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Ajax
- Asynchronous Javascript
- Client-side XSLT
- SAJAX and PHP
- Ajax Resources
- JSON
- Ruby on Rails
- Creating Objects
- Ruby Basics: Arrays and Other Sundry Bits
- Ruby Basics: Iterators and Persistence
- Starting on the Rails
- Rails and Databases
- Rails: Ajax and Partials
- Rails Resources
- Web Services Security
- Web Services Security Resources
- SAML
- Informit Articles and Sample Chapters
- Books and e-Books
- Specification and Implementation
- XML Digital Signatures
- XML Digital Signatures Resources
- XML Key Management Services
- Resources for XML Key Management Services
- Internationalization
- Resources
- Grid Computing
- Grid Resources
- Web Services Resource Framework
- Web Services Resource Framework Resources
- WS-Addressing
- WS-Addressing Resources
- WS-Notifications
- New Languages: XML in Use
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Google Web Toolkit
- GWT Basic Interactivity
- Google Sitemaps
- Google Sitemaps Resources
- Accessibility
- Web Accessibility
- XML Accessibility
- Accessibility Resources
- The Semantic Web
- Defining a New Ontology
- OWL: Web Ontology Language
- Semantic Web Resources
- Google Base
- Microformats
- StructuredBlogging
- Live Clipboard
- WML
- XHTML-MP
- WML Resources
- Google Web Services
- Google Web Services API
- Google Web Services Resources
- The Yahoo! Web Services Interface
- Yahoo! Web Services and PHP
- Yahoo! Web Services Resources
- eBay REST API
- WordML
- WordML Part 2: Lists
- WordML Part 3: Tables
- WordML Resources
- DocBook
- Articles
- Books and e-Books
- Official Documentation and Implementations
- XML Query
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XForms
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Resource Description Framework (RDF)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Topic Maps
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation, Implementations, and Other Resources
- Rich Site Summary (RSS)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Simple Sharing Extensions (SSE)
- Atom
- Podcasting
- Podcasting Resources
- Scalable Vector Graphics (SVG)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- OPML
- OPML Resources
- Summary
- Projects
- JavaScript TimeTracker: JSON and PHP
- The Javascript Timetracker
- Refactoring to Javascript Objects
- Creating the Yahoo! Widget
- Web Mashup
- Google Maps
- Indeed Mashup
- Mashup Part 3: Putting It All Together
- Additional Resources
- Frequently Asked Questions About XML
- What's XML, and why should I use it?
- What's a well-formed document?
- What's the difference between XML and HTML?
- What's the difference between HTML and XHTML?
- Can I use XML in a browser?
- Should I use elements or attributes for my document?
- What's a namespace?
- Where can I get an XML parser?
- What's the difference between a well-formed document and a valid document?
- What's a validating parser?
- Should I use DOM or SAX for my application?
- How can I stop a SAX parser before it has parsed the entire document?
- 2005 Predictions
- 2006 Predictions
- Nick's Book Picks
There is a perception in XML-land that RDF, or the Resource Description Framework, is somehow "complex" or "difficult to understand". This perception has been so strong that it has actually led to resistance to technologies that make use of it, such as the Semantic Web or RSS 1.0. It doesn't have to be that way.
Let's start at the beginning. RDF doesn't actually describe anything. There, I've said it. Just as XML isn't actually a language, but rather a system of rules for creating a new language -- documents must be well-formed, elements must be nested properly, and so on -- RDF is quite literally a framework for describing resources.
So what's a resource? A resource can be just about anything, but at this point it's usually something accessible via a URL, such as a web page or a graphic. (RDF isn't limited to these types of resources, but to keep it simple we'll limit this discussion to them for now.
Then what are we describing? We're describing properties of that resource. For example, we might make the following assertions:
The Vanguard Science Fiction Report has a creator of Nicholas Chase XML Primer Plus has an ISBN of 0672324229 The InformIT Reference Guide has an image of http://www.informit.com/images-psts/topic_icons/xml_e.gif
Now, those might sound a little awkward from a grammatical point of view, but that's how we phrase an assertion:
<resource> has a <property> of <literal value>
(You might also look at it as
Subject predicate object)
You can take that triple and express it as a Resource Graph:
One requirement is that the resource that's being described -- in this case, The Vanguard Science Fiction Report -- has to be specified via a Uniform Resource Identifier (URI). The most common type of URI is a URL, or Uniform Resource Locator, so we can change the graph to show that, as in:
From here, that's pretty clear to a human reading it. Or is it? The term "creator" has lots of different meanings. We could mean the person who wrote the content, or the person who authored the web page, or even God, for that matter. So it would help if we could refer to a specific definition, such as "An entity primarily responsible for making the content of the resource."
Now, as it happens, there is such a defintion that we can reference. The Dublin Core Metadata Initiative (from Dublin Ohio, not Ireland) has created a set of definitions, such as creator, subject, type, and contributor. We could specify that we mean the Dublin Core creator property by including it's full identifier:
At this point the assertion is fairly unambiguous. We know what resource we're describing, and we're clear on exactly the property we're setting. Some might argue that the actual value, "Nicholas Chase," is still ambiguous, and you could, by rights, specify a URI that represents me, but the Dublin Core definition of "creator" recommends that you use a human readable name here. See, we're standardizing things already, and we haven't even put this into XML yet!
Speaking of which, let's do that. What we want to do is create an XML structure that defines the resource that we're describing and provides an unabiguous way of describing it. We'll start with an overall structure:
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="http://www.vanguardreport.com/"> </rdf:Description> </rdf:RDF>
Here we've simply specified that we're describing a resource, and the resource the descriptions are about is http://www.vanguardreport.com. We'll add the actual descriptions in a moment, but before we move on, let's take a good, hard look at what we've got here.
Specifically, note the use of namespaces. If you've only got a passing familiarity with namespaces, you may not have made the connection that the rdf: in rdf:RDF is actually just the alias. It's not the actual namespace. The actual namespace is http://www.w3.org/1999/02/22-rdf-syntax-ns#. This means that the element
rdf:RDF
is actually
http://www.w3.org/1999/02/22-rdf-syntax-ns#RDF
What this means for us is that we can use namespace information to easily specify not only a property, but the full URI for a property, as in:
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rdf:Description rdf:about="http://www.vanguardreport.com/"> <dc:title>The Vanguard Science Fiction Report</dc:title> <dc:creator>Nicholas Chase</dc:creator> </rdf:Description> </rdf:RDF>
By creating the Dublin Core namespace, with an alias of dc:, we've quickly specified the http://purl.org/dc/elements/1.1/creator and http://purl.org/dc/elements/1.1/title properties.
In some cases, the value of the property isn't a literal value, but a separate resource. For example, we can create a RSS 1.0 feed that includes RDF information:
(Note to the observant: Yes, the URL's have been shortened for display purposes.)
<?xml version="1.0" encoding="utf-8"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns="http://purl.org/rss/1.0/"> <channel rdf:about="http://www.informit.com/isapi/topics/guide_rss.xml"> <title>InformIT :: XML Reference Guide</title> <link>http://www.informit.com/</link> <description>The latest weblog and content updates for the InformIT XML Reference Guide</description> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>6</sy:updateFrequency> <sy:updateBase>2003-01-01T12:00+00:00</sy:updateBase> <image rdf:resource="http://www.informit.com/images-psts/topic_icons/xml_e.gif" /> <items> <rdf:Seq> <rdf:li rdf:resource= "http://www.informit.com/weblog/showComments.asp?weblog_id={367F6DB57E04}" /> <rdf:li rdf:resource= "http://www.informit.com/weblog/showComments.asp?weblog_id={878C86686856}" /> </rdf:Seq> </items> </channel> <image rdf:about="http://www.informit.com/images-psts/topic_icons/xml_e.gif"> <title>InformIT XML Reference Guide</title> <url>http://http://www.informit.com/images-psts/topic_icons/xml_e.gif</url> <link>http://www.informit.com/</link> </image> <item rdf:about= "http://www.informit.com/weblog/showComments.asp?weblog_id={367F6DB57E04}"> <title>Blog :: Netscape is dead; Long live Mozilla</title> <link>http://www.informit.com/weblog/showComments.asp?weblog_id={367F6DB57E04}</link> <description>When Netscape released its browser as open-source, it was the Mozilla project that took up the ...</description> </item> <item rdf:about= "http://www.informit.com/weblog/showComments.asp?weblog_id={878C86686856}"> <title>Blog :: RSS 2.0 transferred to neutral party</title> <link>http://www.informit.com/weblog/showComments.asp?weblog_id={878C86686856}</link> <description>Part of the RSS controversy has centered around the perception that RSS 2.0 was somehow ...</description> </item> </rdf:RDF>
We've got a few things going on in this file, so let's take them one at a time. First of all, just because there's no prefix for the RSS namespace (http://purl.org/rss/1.0/) doesn't mean that it doesn't define a set of properties. For example, the image element describes the http://purl.org/rss/1.0/image property of the http://www.informit.com/isapi/topics/guide_rss.xml resource. Second, it just so happens that the value of the image property isn't the string http://www.informit.com/images-psts/topic_icons/xml_e.gif, but rather the resource at that location.
(If the value were the string, it would have been written as:
<image>http://www.informit.com/images-psts/topic_icons/xml_e.gif</image>)
Finally, we're getting a brief glimpse of some of the structure that RDF can provide with the items element. The value of the items property is actually a sequence of resources. The Resource Description Framework defines a number of structures to assist in situations like this.
Overall, we couldn't even begin to cover all of what RDF has to offer in this short piece, but it all boils down to this: RDF creates a way to specify metadata, or data about data, by specifying a resource, the property, and the value of the property. Other organizations can then take this framework and define properties that everyone can agree on so that both people and automated systems can make sense of your information.