Re: Updated URI Template proposal

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}

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

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


   -joe

-- 
Joe Gregorio        http://bitworking.org

Received on Thursday, 8 November 2007 18:28:43 UTC