Marcel Molina (@noradio) recently posted the following announcement to
the Twitter API Announcements list:
http://groups.google.com/group/twitter-api-announce/browse_thread/thread/fa5da2608865453

In it, he describes a new Annotation model consisting of <Namespace,
Key[, Value]> attached to each tweet. One of the sticking points is
that the Annotation must be serializeable to XML, which, depending on
the format picked, imposes certain limitations on the content of
Namespace and Key.

<quote author="@noradio">
  JSON

'annotations':
{
  'iso':
  {
    'isbn': '030759243X'
  },
  'amazon':
  {
    'url': '
http://www.amazon.com/Although-Course-You-Becoming-Yourself/dp/030759...
  }

}

  XML option #1 which is succinct but restricts the possible values of
namespaces and keys

  <annotations>
    <iso>
      <isbn>030759243X</isbn>
    </iso>
    <amazon>
      <url>
http://www.amazon.com/Although-Course-You-Becoming-Yourself/dp/030759...
</url>
    </amazon>
  </annotations>

  XML option #2 which is more verbose but allows for namespaces and
keys to
contain arbitrary data

  <annotations>
    <annotation>
      <namespace>iso</namespace>
      <key>isbn</key>
      <value>030759243X</value>
    </annotation>
    <annotation>
      <namespace>amazon</namespace>
      <key>url</key>
      <value>
http://www.amazon.com/Although-Course-You-Becoming-Yourself/dp/030759...
</value>
    </annotation>
  </annotations>

If we went with XML option #2 it may or may not be a problem that it
isn't
"symmetrical" with the JSON representation. On the other hand, JSON
and XML
tend to be culturally at opposite sides of the Pithiness Spectrum.
</quote>

I, for one, don't mind the restriction on keys being valid XML tag
names, but the restriction on namespaces might be more challenging. In
my opinion, the correct namespace for "ISO" is "net.iso" and that for
"Amazon" is "com.amazon." Indeed, the namespace for this particular
annotation might be "com.amazon.shopping.books."

By adding XML attributes into the mix we might be able to retain the
basic structure of the JSON while allowing a broader set of
namespaces:

<annotations>
  <namespace name="com.amazon.shopping.books">
    <url>http://www.amazon.com/Although-Course-You-Becoming-Yourself/
dp/030759...</url>
  <namespace>
</annotations>

If, on the other hand, we don't mind being a little less JSON-ey and a
little more XML-ey in our XML, we could do

<annotations>
  <isbn ns="org.iso">
    030759243X
  </isbn>
  <url ns="com.amazon.shopping.books">
    http://www.amazon.com/Although-Course-You-Becoming-Yourself/dp/030759...
  </url>
</annotations>

I wish I had some firm answers, but hopefully these ideas will get
some good debate going.

-James

Reply via email to