RE: uri templates: {?var}

Roy,

>> The form-style query expansions {?var} needs to substitute '?' or '&' based on whether or not a '?' already appears in the URI output string being constructed.

> I disagree.  I do not want the expression processor to need
to know the state of the surrounding URI reference.

Not having to know the state of the URI being built is a very MINOR benefit for the (few) developers of template processor libraries. An {?var} operator that looks for any '?' in that state is a MAJOR benefit to (many many) template authors.

Avoiding the surrounding state only works if ALL the query parameters are listed in a single {?var1,var2...} expression. I expect there to be lots of situations where that will not work, or isn't convenient.
* Many situations will have some parameters values fixed by the template author.
* Many situations will use a parameter name in the URI that is different from the variable name (eg "foo?q={searchTerm}"), which cannot be expressed in a {?var} expression as currently specified.
* Some situations will build a template by concatenating expressions to a configured base. You cannot concatenate {?var} if the base might have a query part.


> We then get into a discussion about what happens when {+foo}{?this}
is the template and foo := "hello?".

It would expand to "hello?&this=...", which still delivers a parameter named "this" to CGI scripts.
The current text is worse in this situation. It expands to "hello??this=...". A CGI script will NOT see a "this" parameter as it expects. Instead, it will see a parameter named "?this".

What should happen if foo := "hello?fmt=xml"? Expanding to a URI with 'fmt' and 'this' query parameters is the answer with the least surprise.


>> The text about the '?' operator in 1.1 "Overview" isn't clear on this point. It says '?' is used for the first variable with a defined value in the expression. This is true for the specific example used in the overview, but not true in general (when a template might have some query parameters as literals).

> In that case, the template should not be using the ? operator.
It should be using foo?literal=here&var={variable}

If a template should use
"foo?literal=here&var={var}" instead of "foo?literal=here{?var}"
why not use 
"foo?var1={var1}&var2={var2}" instead of "foo{?var1,var2}"
and drop the whole operator?

The draft 05 text will be nasty for authors that are modifying a template that uses "{?a,b,c,x,y,z}". To add a fmt=xml parameter they have to change all the other parameters: "?fmt=xml&a={a}&b={b}&c={c}&x={x}&y={y}&z={z}".



--
James Manger

Received on Friday, 15 July 2011 01:26:50 UTC