Re: URI templates: comma-separated variable lists

See page 12, paragraph 2
http://tools.ietf.org/html/draft-gregorio-uritemplate-06#page-12

Some URI Templates can be used in reverse for the purpose of variable
> matching: comparing the template to a fully formed URI in order to
> extract the variable parts from that URI and assign them to the named
> variables.  Variable matching only works well if the template
> expressions are delimited by the beginning or end of the URI or by
> characters that cannot be part of the expansion, such as reserved
> characters surrounding a simple string expression.  In general,
> regular expression languages are better suited for variable matching.
>

- Kev
c: +001 (650) 521-7791


On Wed, Aug 24, 2011 at 8:20 AM, Joe Gregorio <joe@bitworking.org> wrote:

> 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 18:51:50 UTC