Home > Articles > Web Services > XML

XML Reference Guide

📄 Contents

  1. XML Reference Guide
  2. Overview
  3. What Is XML?
  4. Informit Articles and Sample Chapters
  5. Books and e-Books
  6. Official Documentation
  7. Table of Contents
  8. The Document Object Model
  9. Informit Articles and Sample Chapters
  10. Books and e-Books
  11. Official Documentation
  12. DOM and Java
  13. Informit Articles and Sample Chapters
  14. Books and e-Books
  15. Implementations
  16. DOM and JavaScript
  17. Using a Repeater
  18. Repeaters and XML
  19. Repeater Resources
  20. DOM and .NET
  21. Informit Articles and Sample Chapters
  22. Books and e-Books
  23. Documentation and Downloads
  24. DOM and C++
  25. DOM and C++ Resources
  26. DOM and Perl
  27. DOM and Perl Resources
  28. DOM and PHP
  29. DOM and PHP Resources
  30. DOM Level 3
  31. DOM Level 3 Core
  32. DOM Level 3 Load and Save
  33. DOM Level 3 XPath
  34. DOM Level 3 Validation
  35. Informit Articles and Sample Chapters
  36. Books and e-Books
  37. Documentation and Implementations
  38. The Simple API for XML (SAX)
  39. Informit Articles and Sample Chapters
  40. Books and e-Books
  41. Official Documentation
  42. SAX and Java
  43. Informit Articles and Sample Chapters
  44. Books and e-Books
  45. SAX and .NET
  46. Informit Articles and Sample Chapters
  47. SAX and Perl
  48. SAX and Perl Resources
  49. SAX and PHP
  50. SAX and PHP Resources
  51. Validation
  52. Informit Articles and Sample Chapters
  53. Books and e-Books
  54. Official Documentation
  55. Document Type Definitions (DTDs)
  56. Informit Articles and Sample Chapters
  57. Books and e-Books
  58. Official Documentation
  59. XML Schemas
  60. Informit Articles and Sample Chapters
  61. Books and e-Books
  62. Official Documentation
  63. RELAX NG
  64. Informit Articles and Sample Chapters
  65. Books and e-Books
  66. Official Documentation
  67. Schematron
  68. Official Documentation and Implementations
  69. Validation in Applications
  70. Informit Articles and Sample Chapters
  71. Books and e-Books
  72. XSL Transformations (XSLT)
  73. Informit Articles and Sample Chapters
  74. Books and e-Books
  75. Official Documentation
  76. XSLT in Java
  77. Java in XSLT Resources
  78. XSLT and RSS in .NET
  79. XSLT and RSS in .NET Resources
  80. XSL-FO
  81. Informit Articles and Sample Chapters
  82. Books and e-Books
  83. Official Documentation
  84. XPath
  85. Informit Articles and Sample Chapters
  86. Books and e-Books
  87. Official Documentation
  88. XML Base
  89. Informit Articles and Sample Chapters
  90. Official Documentation
  91. XHTML
  92. Informit Articles and Sample Chapters
  93. Books and e-Books
  94. Official Documentation
  95. XHTML 2.0
  96. Documentation
  97. Cascading Style Sheets
  98. Informit Articles and Sample Chapters
  99. Books and e-Books
  100. Official Documentation
  101. XUL
  102. XUL References
  103. XML Events
  104. XML Events Resources
  105. XML Data Binding
  106. Informit Articles and Sample Chapters
  107. Books and e-Books
  108. Specifications
  109. Implementations
  110. XML and Databases
  111. Informit Articles and Sample Chapters
  112. Books and e-Books
  113. Online Resources
  114. Official Documentation
  115. SQL Server and FOR XML
  116. Informit Articles and Sample Chapters
  117. Books and e-Books
  118. Documentation and Implementations
  119. Service Oriented Architecture
  120. Web Services
  121. Informit Articles and Sample Chapters
  122. Books and e-Books
  123. Official Documentation
  124. Creating a Perl Web Service Client
  125. SOAP::Lite
  126. Amazon Web Services
  127. Creating the Movable Type Plug-in
  128. Perl, Amazon, and Movable Type Resources
  129. Apache Axis2
  130. REST
  131. REST Resources
  132. SOAP
  133. Informit Articles and Sample Chapters
  134. Books and e-Books
  135. Official Documentation
  136. SOAP and Java
  137. Informit Articles and Sample Chapters
  138. Books and e-Books
  139. Official Documentation
  140. WSDL
  141. Informit Articles and Sample Chapters
  142. Books and e-Books
  143. Official Documentation
  144. UDDI
  145. UDDI Resources
  146. XML-RPC
  147. XML-RPC in PHP
  148. Informit Articles and Sample Chapters
  149. Books and e-Books
  150. Official Documentation
  151. Ajax
  152. Asynchronous Javascript
  153. Client-side XSLT
  154. SAJAX and PHP
  155. Ajax Resources
  156. JSON
  157. Ruby on Rails
  158. Creating Objects
  159. Ruby Basics: Arrays and Other Sundry Bits
  160. Ruby Basics: Iterators and Persistence
  161. Starting on the Rails
  162. Rails and Databases
  163. Rails: Ajax and Partials
  164. Rails Resources
  165. Web Services Security
  166. Web Services Security Resources
  167. SAML
  168. Informit Articles and Sample Chapters
  169. Books and e-Books
  170. Specification and Implementation
  171. XML Digital Signatures
  172. XML Digital Signatures Resources
  173. XML Key Management Services
  174. Resources for XML Key Management Services
  175. Internationalization
  176. Resources
  177. Grid Computing
  178. Grid Resources
  179. Web Services Resource Framework
  180. Web Services Resource Framework Resources
  181. WS-Addressing
  182. WS-Addressing Resources
  183. WS-Notifications
  184. New Languages: XML in Use
  185. Informit Articles and Sample Chapters
  186. Books and e-Books
  187. Official Documentation
  188. Google Web Toolkit
  189. GWT Basic Interactivity
  190. Google Sitemaps
  191. Google Sitemaps Resources
  192. Accessibility
  193. Web Accessibility
  194. XML Accessibility
  195. Accessibility Resources
  196. The Semantic Web
  197. Defining a New Ontology
  198. OWL: Web Ontology Language
  199. Semantic Web Resources
  200. Google Base
  201. Microformats
  202. StructuredBlogging
  203. Live Clipboard
  204. WML
  205. XHTML-MP
  206. WML Resources
  207. Google Web Services
  208. Google Web Services API
  209. Google Web Services Resources
  210. The Yahoo! Web Services Interface
  211. Yahoo! Web Services and PHP
  212. Yahoo! Web Services Resources
  213. eBay REST API
  214. WordML
  215. WordML Part 2: Lists
  216. WordML Part 3: Tables
  217. WordML Resources
  218. DocBook
  219. Articles
  220. Books and e-Books
  221. Official Documentation and Implementations
  222. XML Query
  223. Informit Articles and Sample Chapters
  224. Books and e-Books
  225. Official Documentation
  226. XForms
  227. Informit Articles and Sample Chapters
  228. Books and e-Books
  229. Official Documentation
  230. Resource Description Framework (RDF)
  231. Informit Articles and Sample Chapters
  232. Books and e-Books
  233. Official Documentation
  234. Topic Maps
  235. Informit Articles and Sample Chapters
  236. Books and e-Books
  237. Official Documentation, Implementations, and Other Resources
  238. Rich Site Summary (RSS)
  239. Informit Articles and Sample Chapters
  240. Books and e-Books
  241. Official Documentation
  242. Simple Sharing Extensions (SSE)
  243. Atom
  244. Podcasting
  245. Podcasting Resources
  246. Scalable Vector Graphics (SVG)
  247. Informit Articles and Sample Chapters
  248. Books and e-Books
  249. Official Documentation
  250. OPML
  251. OPML Resources
  252. Summary
  253. Projects
  254. JavaScript TimeTracker: JSON and PHP
  255. The Javascript Timetracker
  256. Refactoring to Javascript Objects
  257. Creating the Yahoo! Widget
  258. Web Mashup
  259. Google Maps
  260. Indeed Mashup
  261. Mashup Part 3: Putting It All Together
  262. Additional Resources
  263. Frequently Asked Questions About XML
  264. What's XML, and why should I use it?
  265. What's a well-formed document?
  266. What's the difference between XML and HTML?
  267. What's the difference between HTML and XHTML?
  268. Can I use XML in a browser?
  269. Should I use elements or attributes for my document?
  270. What's a namespace?
  271. Where can I get an XML parser?
  272. What's the difference between a well-formed document and a valid document?
  273. What's a validating parser?
  274. Should I use DOM or SAX for my application?
  275. How can I stop a SAX parser before it has parsed the entire document?
  276. 2005 Predictions
  277. 2006 Predictions
  278. Nick's Book Picks

In one of my predictions for 2006, I said that "RSS will have become so common that every application for which it makes sense (and probably a few for which it doesn't) will provide an RSS feed for various purposes." Specifically, RSS is being used as a type of announcement service, which makes sense for its original usage, as a listing of blog entries or other web pages of interest. On the other hand, and applications also use RSS as a means for disseminating information on items such as files that are now available, contacts in your address book, appointments in your calendar, and so on.

In many cases, this is information that is shared among multiple points. For example, Ray Ozzie talks about the fact that when he is traveling, he has difficulty coordinating his calendar with his wife. Ideally, he thought, we could find a way to synchronize her copy and my copy. And thus, Simple Sharing Extensions, or SSE, was born.

The purpose of SSE is to add information to an RSS feed (or, as stated in the spec, an OPML outline) that enables users to share the information without stepping on each other. In other words, it adds information that uniquely identifies each item so that it can be included in separate feeds without ambiguity, and allows for changes that can be detected and managed by other users. The spec is just been released, and as such still has a ways to go, but it's useful enough in its current state that it's worth looking at and putting into practice, if only to find all the holes.

As such, I thought I'd take some time to demonstrate how SSE can be used to share information between RSS feeds. Although it was originally conceived for feeds that are, say, informational rather than traditional syndication feeds, I do think that there's a place for it in the traditional RSS world. For example, many bloggers -- myself included -- have more than one blog. How to get all of that information together in one place has been a problem. Oh sure, I could just create one RSS feed that includes all of the information, but that just always seemed kind of messy to me. With SSE, I can create an aggregate feed and keep the information properly segregated.

You can also use SSE to create general aggregate feeds. Consider for a moment this example:

Chart of linked feeds

In this case, we have several feeds that are mutually publishing and subscribing to each other. For example, the Chaos Magnet feed includes items from the InformIT feed. Chaos Magnet is then subsequently included in Troy's feed, which includes the blogs of people who work with Backstop Media. Finally, I can create an overall aggregate feed of items that I want to watch for. Note that I wouldn't necessarily have to include Chaos Magnet, in this case, because it's already part of the Backstop feed, but as I own it, I would likely want to maintain it separately. In this case, it would be useful to have unique identifiers for each item so they are not duplicated. And, in fact, SSE provides for that. Let's take a look at how it works.

Consider, for a moment, my original Chaos Magnet feed, which happens to be an RSS 1.0 RDF document:

<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.chaosmagnet.com/blog/">
<title>Chaos Magnet</title>
<link>http://www.chaosmagnet.com/blog/</link>

<description>The personal and professional ramblings of Nicholas Chase.</description>
...
<items>
  <rdf:Seq><rdf:li rdf:resource="http://www.chaosmagnet.com/blog/archives/000727.html" />
    <rdf:li rdf:resource="http://www.chaosmagnet.com/blog/archives/000726.html" />
    <rdf:li rdf:resource="http://www.chaosmagnet.com/blog/archives/000725.html" />

...
  </rdf:Seq>
</items>

</channel>

<item rdf:about="http://www.chaosmagnet.com/blog/archives/000727.html">
  <title>Virus catches child porn offender</title>
  <link>http://www.chaosmagnet.com/blog/archives/000727.html</link>

  <description>The other day Sarah told me she was a bit disturbed because she'd received an email from the FBI saying they'd found that she had visited illegal web sites. Having received many of these fake emails (usually purporting to be...</description>
  <dc:subject>Technology</dc:subject>
  <dc:creator>roadnick</dc:creator>

  <dc:date>2005-12-22T09:39:24-05:00</dc:date>
</item>

<item rdf:about="http://www.chaosmagnet.com/blog/archives/000726.html">
  <title>Graduation:  it's not just for soldiers anymore</title>
  <link>http://www.chaosmagnet.com/blog/archives/000726.html</link>

  <description>Well, I'm back from South Carolina and Sean's graduation from Basic Combat Training. After all those years of official school papers coming home and talking about "your child" it was a bit jarring, to say the least, to receive a...  </description>
  <dc:subject>Personal</dc:subject>
  <dc:creator>roadnick</dc:creator>

  <dc:date>2005-12-12T20:21:04-05:00</dc:date>
</item>

<item rdf:about="http://www.chaosmagnet.com/blog/archives/000724.html">
<title>Nerdier than I thought</title>
...
</item>


</rdf:RDF>

The feed contains information about itself, and then the individual items to be syndicated. What we need to do is add information to the feed about the what it includes, and information to each item to facilitate its being shared.

We start by defining a new namespace for the additional information:

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

<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
...
  xmlns:sx=http://www.microsoft.com/schemas/rss/sse"

  xmlns="http://purl.org/rss/1.0/">

<channel rdf:about="http://www.chaosmagnet.com/blog/">
<title>Chaos Magnet</title>
...

This will enable us to add whatever information we need without disturbing the validity of the actual RSS information.

We need to add information about what is actually being shared in this feed:

...
<channel rdf:about="http://www.chaosmagnet.com/blog/">
  <title>Chaos Magnet</title>
  <link>http://www.chaosmagnet.com/blog/</link>
  <description>The personal and professional ramblings of Nicholas Chase.</description>

...

  <sx:sharing window="10" since="Sun, 1 January 2005 12:28:32 GMT"
                       until="Thu, 12 January 2006 09:02:47 GMT">
     <sx:related link="http://www.nicholaschase.com/blog/completefeed.rdf"
               type="complete" title="Chaos Magnet: ALL entries" />
     <sx:related link="http://www.informit.com/guides/guide_rss.asp?g=xml"
               type="aggregated" title="InformIT's XML and Web Services Blog" />
  </sx:sharing>
       
  <items>
    <rdf:Seq>

      <rdf:li rdf:resource="http://www.chaosmagnet.com/blog/archives/000727.html" />
      <rdf:li rdf:resource="http://www.chaosmagnet.com/blog/archives/000726.html" />
...
    </rdf:Seq>
  </items>

</channel>
...

Starting with the sharing element, we are essentially adding the information that will enable the user (or tool, for that matter) to get more information on the resources that are being shared. The window attribute specifies how long changes are kept. For example, in this case, any change is older than 10 days will not be available in this feed. The feed itself contains data from as far back as January 1, 2005, and as recent as January 12, 2006. Note, however, that that does not mean that all of that information is included, just that no information outside of that window is included.

Next let's look at the related elements. Each one describes the feed involved in this aggregated feed. First, we see information on where to obtain a feed that includes all of the Chaos Magnet entries. Now, for a blog this doesn't make particular sense, but in the case of, say, a shared contact list, in which a user or subscribing to this feed will want to obtain the complete set before making incremental changes, it's crucial. The type attribute specifies how the feed is related. In the case of the first entry, as I said, we are specifying a complete feed.

Next, I'm including information on my InformIT blog, which I'm aggregating into this feed, as you can see from the type attribute. Including this information enables a person (again, or tool) to get information on the original source. The spec also provides for optional since and until attributes for the related element.

(I should note here that the initial specification is unclear as to whether the title should be an attribute (as in the seemingly normative description) or child element (as in the examples). Until told otherwise, I choose to stick with the description. Your mileage may vary until the final version of the spec is released.)

Now let's look at individual items:

...
<items>
  <rdf:Seq>
    <rdf:li rdf:resource="http://www.chaosmagnet.com/blog/archives/000727.html" />
    <rdf:li rdf:resource="http://www.informit.com/discussion/index.asp?postid=9207b767-34e5-41c2-8768-05d831b6729e&f1=rss" />

    <rdf:li rdf:resource="http://www.chaosmagnet.com/blog/archives/000726.html" />
    <rdf:li rdf:resource="http://www.chaosmagnet.com/blog/archives/000725.html" />
...
  </rdf:Seq>
</items>

</channel>

<item rdf:about="http://www.chaosmagnet.com/blog/archives/000727.html">

  <sx:sync id="http://www.chaosmagnet.com/blog/archives/000727.html" 
           version="5" />
  <title>Virus catches child porn offender</title>
  <link>http://www.chaosmagnet.com/blog/archives/000727.html</link>
  <description>The other day Sarah told me she was a bit disturbed because she'd received an email from the FBI saying they'd found that she had visited illegal web sites. Having received many of these fake emails (usually purporting to be...</description>

  <dc:subject>Technology</dc:subject>
  <dc:creator>roadnick</dc:creator>
  <dc:date>2005-12-22T09:39:24-05:00</dc:date>
</item>

<item rdf:about="http://www.informit.com/discussion/index.asp?postid=9207b767-34e5-41c2-8768-05d831b6729e&f1=rss">
  <sx:sync id="http://www.informit.com/discussion/index.asp?postid=9207b767-34e5-41c2-8768-05d831b6729e" 
           version="1" />
  <title>Blog :: Artificial artificial intelligence: Amazon's Mechanical Turk</title>
  <link>http://www.informit.com/discussion/index.asp?postid=9207b767-34e5-41c2-8768-05d831b6729e&f1=rss</link>

</item>

<item rdf:about="http://www.chaosmagnet.com/blog/archives/000726.html">
  <sx:sync id="http://www.chaosmagnet.com/blog/archives/000726.html" 
           version="1" />
  <title>Graduation:  it's not just for soldiers anymore</title>
  <link>http://www.chaosmagnet.com/blog/archives/000726.html</link>

...

First, I should note, almost as of version issue, because I'm using RSS 1.0, if I include any additional entries in my feed, I need to add them to the items element in the channel. For other versions of RSS, this is not an issue.

Next, let's look at the individual items themselves. First off, notice that every item to be included in this shared scheme must include a sync element. This element includes a unique identifier for the item. The actual form of the unique identifier is arbitrary; choose what you like, but it must be unique across feeds. For this reason, I prefer to use the URL for the entry, though there are others that would disagree. To me, it is the only way to maintain a truly unique identifier.

The sync element also includes a version attribute that enables you to determine if the entry has been edited since the last time you downloaded the feed. This is an integer value that must start at 1 and be incremented by 1 every time a change is made.

The specification also provides for two additional attributes for the sync element. The first, deleted, enables you to create a sort of "tombstone" for an entry that has been removed. The second, conflict arises in the situation in which two people have edited the same entry and have "stepped on" each other's changes.

In fact, SSE enables you to track the history of an item. For example, you may notice that the first entry in the feed has a version number of 5. Optionally, we can track the history of these changes:

...
<item rdf:about="http://www.chaosmagnet.com/blog/archives/000727.html">
  <sx:sync id="http://www.chaosmagnet.com/blog/archives/000727.html" 
           version="5" conflict="true">
        <sx:history when="Tue, 10 January 2006 11:22:08 GMT" by="roadnick">
            <sx:update when="Tue, 10 January 2006 11:22:08 GMT"
                    by="roadnick" />

            <sx:update when="Mon, 09 January 2006 17:09:54 GMT"
                    by="sorcha" />
            <sx:update when="Mon, 02 January 2006 07:46:18 GMT"
                    by="roadnick" />
        </sx:history>
        <sx:conflicts>
            <sx:conflict when="Tue, 10 January 2006 13:26:08 GMT"
                    by="sorcha"
                    version="5">
                <item>

                      <description>The other day Sarah told me she was a bit concerned because she'd received an email from the FBI saying they'd found that she had visited illegal web sites. Having received many of these fake emails (usually purporting to be...</description>
                </item>
            </sx:conflict>
        </sx:conflicts>
  </sx:sync>

  <title>Virus catches child porn offender</title>
...

The history element includes information on when the item was updated, and/or by whom. (One of these pieces of information must be provided.) This element also contains a chronological history of the changes, each also having information on when and/or by whom the changes were made. By including information on who made the changes, you can "break the tie" so to speak if there's a question as to who's edit should take precedence. Note that you are not required to keep all changes, but you can only delete the oldest.

In the case of a conflict, you have the option to include information on what the conflict actually was using the conflicts element. This element enables you to note when the conflicting change was made, and by whom, as well as what version is in question. You also have the option of including the actual changes that were in question in the body of the element. SSE provides an algorithm for determining whether or changes conflict, as well as a process for "resolving" these conflicts so that changes can continue to be made.

And that, in a nutshell, is it. I've focused here on RSS 1.0 because that was the example I was using, but the specification refers only to SSE in RSS in general. It also defines how SSE can be used in OPML files. What's more, there's nothing stipping you from using SSE in other syndication formats such as Atom.

At the time of this writing, the spec is just been released, and there's no sample code that implements it, but in general it is fairly straightforward. At the very least, you can add this extension to your own RSS feeds, so that when someone finally built an aggregator that pays attention to them, your content will already be SSE enabled.

For more information on Simple Sharing Extensions, check out the following:

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.