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:44:26 -0400
Message-ID: <47293D8A.1090702@anconafamily.com>
To: uri@w3.org

After working with Joe's syntax a bit, I like it. One area that seems a 
bit week is construct that support query variables.

Optional variables aren't too bad:

http://example.com/foo?{,&|opt1,opt2,opt3}

I don't think there's a way to omit the '?' when no parameters are present.

Required variables don't have the question mark problem (since it's 
required):

http://example.com/foo?req1={req1}&req2={req2}

The disadvantage here is that the syntax implies the the order of 
parameters is significant, while in fact it shouldn't be.

I can't find a way to combine the {,&|...} syntax for optional 
parameters with required parameters as defined above, because there's no 
way to insert the ampersand between the required and optional parameters.

I can do both required and optional parameters like this:

http://example.com/foo?req1={req1}&req2={req2}{<&opt1=|opt1}{<&opt2=|opt2}

That again implies an ordering of parameters that shouldn't exist. The 
ordering issue bothers me because of my interest in extracting variable 
values from a URI based on a template. (See my previous message.) My 
current implementation would properly handle URIs generated from the 
template immediately above, but would fail when presented with input 
from things like HTML forms where the order of params can't be controlled.

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

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