W3C home > Mailing lists > Public > uri@w3.org > November 2007

Re: Updated URI Template proposal

From: James M Snell <jasnell@gmail.com>
Date: Thu, 08 Nov 2007 11:06:01 -0800
Message-ID: <47335E19.7070500@gmail.com>
To: Joe Gregorio <joe@bitworking.org>
CC: URI <uri@w3.org>

Joe Gregorio wrote:
> On 11/5/07, James M Snell <jasnell@gmail.com> wrote:
>> Lastly, you had previously mentioned that the cardinality of vars with
>> the join op was an issue.  Could we not use +, * and ? for that?
> I think cardinality can be solved at a more
> granular level by choosing between
> listjoin and join.
>     {-listjoin|&num=|numbers}
>     {-join|&|num}

Ok, so what I want to achieve is a url structure like:


Using listjoin and join, that would come out to:


Alternatively, if we went with *, it would come out to:


Both would work.  The former is obviously more generalized than the
second and the approach works well with other URL segments (like your
gdata categories example).  The latter is (in my opinion) more concise
and readable.

> What I do think can be done is indicate if a variable is optional or required.
> Maybe append the variable name with '+' if the variable is required?
>     {num+}                     // num is required
>     {-join|&|num,start-index,q+}   // q is required, num and
> start-index are optional

That works.

> Note that setting a default value for a required element is
> redundant, since if you don't supply a value the default will be
> used. So this could probably be allowed, since it doesn't hurt
> anything, but it doesn't add much:
>    {num+=2}
> Allowing it keeps the parsing simple, as you don't have to add
> a rule to forbid it. And this now allows you to neatly cover all the
> cardinality cases you mentioned using a combination of
> join, listjoin, and requiredness:
>     {num}               // 0 or 1
>     {num+}             // 1
>     {-join|&|num}     // 0 or more
>     {-join|&|num+}   // 1 or more

wouldn't that be:

     {-join|&|num}           // 0 or 1
     {-join|&|num+}          // 1
     {-listjoin|&num=|nums}  // 0 or more
     {-listjoin|&num=|nums+} // 1 or more

Several more questions:

* I assume that {-join|&|start,count} resolves to "start=foo&count=bar"
and not "&start=foo&count=bar" (note the leading & in the latter).

* I also assume that the ordering of the var's in the -join is
insignificant?  e.g. given {-join|&|start,count} the results
"start=foo&count=bar" and "count=bar&start=foo" are equivalent and

* Given {-opt|?|tags,start,count}, the ? is inserted if at least one of
the members of the set is defined.  That is, if tags is defined but
start and count are not, the ? will still be inserted.

- James
Received on Thursday, 8 November 2007 19:06:25 UTC

This archive was generated by hypermail 2.4.0 : Sunday, 10 October 2021 22:17:50 UTC