Re: URI Templates - optional variables?

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 UTC