Re: URI Templates - optional variables?

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 UTC