W3C home > Mailing lists > Public > uri@w3.org > November 2007

Re: URI Templates - optional variables?

From: Jim Ancona <jim@anconafamily.com>
Date: Wed, 31 Oct 2007 22:04:33 -0400
Message-ID: <47293431.9010805@anconafamily.com>
To: uri@w3.org

Hi,

I've been lurking here for a bit and have read the threads on Joe's 
latest proposal. Like Marc Hadley, I see the ability to match templates 
to URIs and extract values of variables as valuable because it allows 
the same template to be used to both generate and parse, so there is no 
possibility of the spec for the client to be out of sync with the 
behavior of the server.

While Joe and John Cowan are correct that the current proposal is not 
generally invertible, it seems to me that the only interesting templates 
are those that are invertible--otherwise how would the server infer what 
the client meant?

I've written a template parser (in Java) that can go in either direction 
(template+variables->URI or URI+template->template). It resolves 
ambiguities by matching greedily.

Here are John's and Joe's examples of ambiguous matches, with my 
program's resolution of them.

Template:   /{foo}{bar}/
URI:        /whatever/
Variables:  foo => 'whatever', bar => ''

Template:   http://example.org{?/|a}{?/|b}
URI:        http://example.org/
Variables:  a => 'true', b => null

It might be difficult to specify a non-ambiguous language. It might be 
worthwhile to warn users of the pitfalls of non-reversible templates.

Once I can get my employer's OK, I'll pass my code along to Joe in case 
he wants to put it up on the uri-templates Google Code site.

Jim Ancona
Received on Friday, 2 November 2007 22:17:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 13 January 2011 12:15:37 GMT