CMIS VIII: Futile to model Atom using XSD

The CMIS AtomPub bindings include a W3C schema for XML, aka XSD for Atom, in a file called atom.xsd. I wanted to warn potential users of that schema about the perils of validating against that schema.

First of all, Atom’s syntax has been specified using RNG. There are programmatic Atom validators to ascertain whether an Atom document meets the requirements of RFC4287. There  is a very good reason to not use XSD for modeling Atom – its open extension model.
If you have done any application programming with Atom formats, you would know that Atom allows foreign mark-up to be used anywhere (pretty much). That means you can arbitrarily interleave the elements from Atom’s namespace with those from a foreign namespace. XSD does not have any mechanism to allow this. For example, in the document below, the highlighted mark up could occur anywhere except after the entry close tag:

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:f="http://example.com"> <title>Example Feed</title>
<link href="http://example.org/"/>
<updated>2003-12-13T18:30:02Z</updated>
<author>
<name>John Doe</name>
</author>
<f:foreign>something<f:foreign>
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
<entry>
<title>Atom-Powered Robots Run Amok</title>
<link href="http://example.org/2003/12/13/atom03"/>
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
<updated>2003-12-13T18:30:02Z</updated>
<summary>Some text.</summary>
</entry>
</feed>

The only restriction on foreign markup is that it cannot occur directly under the feed element anywhere after the first entry element. I highlighted a problem in CMIS with this concept in a previous blog post that explains why hasMoreItems results in invalid Atom documents.

Leave a Reply

Your email address will not be published. Required fields are marked *