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

Re: URI Templates - optional variables?

From: Joe Gregorio <joe@bitworking.org>
Date: Tue, 16 Oct 2007 01:01:36 -0400
Message-ID: <3f1451f50710152201x5510859fv91dd5bddf90003d6@mail.gmail.com>
To: "Roy T. Fielding" <fielding@gbiv.com>
Cc: URI <uri@w3.org>, "Stefan Eissing" <stefan.eissing@greenbytes.de>, "Mark Nottingham" <mnot@mnot.net>

On 10/15/07, Roy T. Fielding <fielding@gbiv.com> 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

+1

> To tie this back to my earlier messages on Aug 1, substituting
> pipe ("|") for ":", "<" for "?", adding ">" for suffix, and
> "+" for simple joins:
>
>     {variable}                                   (substitute)
>        Substitute the value of variable.
>
>     {=default|variable}                          (sub w/default)
>        If variable is defined and non-empty, then substitute the
>        value of variable.  Otherwise, substitute with the default
>        value defined by the string of non-pipe characters between
>        the '=' and '|', if any.
>            E.g.,  {=red|favoritecolor}  = "value" or "red"
>
>     {<prefix|variable}                           (prefixed sub)
>        If variable is defined and non-empty, then substitute the
>        string of non-pipe characters between the '<' and '|', if
>        any, followed by the value of variable.  Otherwise,
>        substitute with the empty string.
>           E.g.,   {</|variable}       = "/value"      or ""
>                   {<;name=|variable}  = ";name=value" or ""
>                   {<#|variable}       = "#value"      or ""

I started with your proposal as inspiration, but did modify it
and one of the reasons is the above two operators. If you look
at my proposal the prefix operator can have a default
value, i.e. defaulting is not an operator unto itself.


> The main use case for substring substitution is to describe
> automated resource hierarchies that aren't flat, such as lists of
> users within a large intranet that are tree-balanced by splitting
> into sub-collections by the first character of the last name

I had dropped substring substitution from my proposal because
I couldn't think of a use for it, but this is obviously a compelling
use case and it should be supported.

   -joe

-- 
Joe Gregorio        http://bitworking.org
Received on Tuesday, 16 October 2007 05:01:45 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 13 January 2011 12:15:37 GMT