Re: URI templates: comma-separated variable lists

On Wed, Aug 24, 2011 at 9:50 AM, James Manger <James@manger.com.au> wrote:
> draft-gregorio-uritemplate-06.txt allows a comma-separated list of variables in any expression, regardless of the expression operator.
>
> However, a list should not be used with 5 of the 8 operators (+ # . / and no operator) because an expansion will be ambiguous if any variable in the list is undefined. The server cannot tell which value goes with which variable.

URI Templates are for expansion and not parsing, so the use case of
trying to figure out which value goes with which variable is not a
supported use case.
If it were then there would be more problems than with just lists. For
example, how would the template

  "{a}{b}"

match this incoming string:

  "foobar"

a = "f"
b = "oobar"

or would it be:

  a = "foo"
  b = "bar"

or maybe

  a = "foobar"
  b = ""

  -joe

>
> Consider if the template "{alpha,beta,gamma}" is expanded to "23,6". The user could have provided alpha=23 beta=6, or alpha=23 gamma=6, or beta=23 gamma=6 (or beta=[23,6] but that is a separate bug).
>
> A template like "{alpha,beta,gamma}" is almost certainly a mistake by the template author. It only makes any sense if all the variables are mandatory, but in that case it is clearer to use "{alpha},{beta},{gamma}" -- with no chance of ambiguity (and simpler lower-level expressions).
>
> I suggest changing the spec ABNF to only allow variable lists with operators that produce name=value pair (or drop variable lists entirely).
>
> --
> James Manger
>



-- 
Joe Gregorio        http://bitworking.org

Received on Wednesday, 24 August 2011 15:20:58 UTC