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

Re: URI Templates - optional variables?

From: Roy T. Fielding <fielding@gbiv.com>
Date: Mon, 15 Oct 2007 18:47:01 -0700
Message-Id: <9FD1F413-B4A2-48FC-A83E-7147E275A702@gbiv.com>
Cc: URI <uri@w3.org>, Joe Gregorio <joe@bitworking.org>, Stefan Eissing <stefan.eissing@greenbytes.de>
To: Mark Nottingham <mnot@mnot.net>

On Oct 15, 2007, at 6:03 PM, Mark Nottingham wrote:
> On 16/10/2007, at 10:11 AM, Roy T. Fielding wrote:
>> I think it is critical to limit the potential operations to
>> typical string operations, both for simplicity of implementation
>> and also for our capacity to understand the template without
>> needing to refer to external rules or processing.  There is no
>> reason to have URI templates if we don't limit them to a
>> declarative syntax
> Agreed; I didn't mean to imply anything else. My concern was more  
> that we'd be able to cover the diversity of use cases we've heard  
> about (much less hadn't come across yet) with a reasonably-sized  
> library of operators in one go.

I was actually responding to Stefan's suggestion that we include
function names for arbitrarily namespaced actions.  If we are trying
to solve a declarative problem, we need to stick to self-descriptive

> WRT "string operations": what about allowing variable values to be  
> lists of strings? E.g., this seems like it would be useful:
> template: http://example.org/sausage?{,&condiments}
> condiments = ["tomato sauce", "chutney", "relish"]
> result: http://example.org/sausage?condiments=tomato% 
> 20sauce&condiments=chutney&condiments=relish
> Otherwise, I've got to define condiment1, condiment2, and so on, or  
> fall back to simple substitution and build it myself.

I think that is mixing up Joe's join syntax and my param=value
substitution (the & operator is confusing, which is why I used
plus "+" for my simple joins and comma "," for param=value).

I am struggling to think of a use case for arrays in real practice.
I could understand modifying join such that it treats single variables
with array values the same as multiple variables with single values,

   http://example.org/sausage?{+,|condiments} =

but I can't think of a case where I would need that for a web service.
Also, how does the reader of the template know that the variable is
supposed to be an array?  Hmm, how about

   name    = "Roy"
   address = ["23 Corporate Plaza DR", "Suite 215",
              "Newport Beach, CA 92660", "USA"]

    http://example.org/checkaddress{,&|name,address} =

That would work.  The ',' operator would then supply the template
reader with an expectation that multi-valued parameters should be
listed with a numeric suffix for values N>1.

An alternative would be to go the perl direction and add a form
of type annotation to the variable names, as in


but variable types might be a slope too slippery.

Received on Tuesday, 16 October 2007 01:47:20 UTC

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