Re: URI Templates - optional variables?

On Aug 1, 2007, at 3:02 PM, Roy T. Fielding wrote:
>    {%separator:hashvar}
>         For each variable named in the value of hashvar (which could
>         be a space-separated string or some context-dependent hash
>         mechanism), if the named variable is defined and non-empty,
>         then substitute the concatenation of variable name, "=",
>         variable value.  If more than one substitution is made,
>         separate each substitution with the string of non-colon
>         separator characters between the '%' and ':'.
>            E.g.,   myhash = "name age sex location"
>                      name = "Fred"
>                       age = "41"
>                       sex = ""
>                  location = "USA"
>
>            then  {%&:myhash} = "name=Fred&age=41&location=USA"

Actually, that one isn't very useful for resource description.
An explicit list would be better:

    {,separator:var1,var2,var3,...}
         For each variable named in the comma-separated list,
         if the named variable is defined and non-empty, then
         substitute the concatenation of variable name, "=",
         variable value.  If more than one substitution is made,
         separate each substitution with the string of non-colon
         separator characters between the ',' and ':'.
            E.g., name     = "Fred"
                  age      = "41"
                  sex      = ""
                  location = "USA"
         {,&:name,age,sex,location} = "name=Fred&age=41&location=USA"

I hope it is clear what the use cases for that would be.

....Roy

Received on Thursday, 2 August 2007 00:32:15 UTC