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

Re: URI Templates - optional variables?

From: Mark Nottingham <mnot@mnot.net>
Date: Mon, 15 Oct 2007 16:56:46 +1000
Message-Id: <DACEFB11-EBD5-466C-9896-4F514D863644@mnot.net>
Cc: "Roy T. Fielding" <fielding@gbiv.com>, uri@w3.org
To: Joe Gregorio <joe@bitworking.org>

That's what I've been saying all along -- obviously not very well :)

IIRC, the issue that we never really resolved is invoking the  
template rules; i.e. deciding when to look for and apply the special  
syntax.

We can come up with a library of rules for different scenarios (good  
start in the other thread, btw), but we'll never be able to cover all  
of the specialist cases. As such, there needs to be a way for a  
template variable to specify additional processing, and for template  
processing engines to be extended.

If we accept that, the question is whether the default rules we  
define (e.g., the ones you listed) get applied automatically to all  
templates, or whether they have to be specified as relevant to a  
template variable or not. Automatically invoking them makes those  
common cases easier, but restricts the syntax of template variables  
-- and I understand that some people want to do things like put URIs  
in template variable names (e.g., for RDF).

It's a trade-off, and there are good arguments for both sides; I just  
want to make sure that we make a conscious decision about it. I have  
a feeling that unless someone stands up and yells soon, they'll get  
applied to all templates.

Cheers,


On 06/10/2007, at 4:19 AM, Joe Gregorio wrote:

>
> On 8/10/07, Mark Nottingham <mnot@mnot.net> wrote:
>>
>> On 02/08/2007, at 8:02 AM, Roy T. Fielding wrote:
>>
>>> I still think that URI templates need to define a syntax for
>>> defaulting and other common string substitutions, even if the
>>> initial authors have no need of it.
>>
>> It's not that we don't have need of it, it's just that we haven't got
>> a good answer for it yet, and we've been focused on the encoding
>> issue. I, for one, am very open to suggestions.
>
> True, but as I dig back into URI Templates I realize that
> these substitutions actually *fix* the encoding issue.
>
> Very quickly, with a rule like:
>
>          {,&:name,age,sex,location} = "name=Fred&age=41&location=USA"
>
> we can avoid worrying about whether or not to escape
> '&', '=', and '?' in the values of name, age, sex, and location.
> That was a major stumbling block and I've now put together enough
> examples to convince myself that we can *never* guess correctly,
> even if we take a URI component by component. With a set of templating
> rules like the ones Roy has suggested we can get away with
> a simple encoding rule: everything outside 'pchar' should be  
> percent-encoded.
> (Actually, if the values are unicode then convert to utf-8 and then
>   percent-encode values outside pchar).
>
>    Thanks,
>    -joe
>
> -- 
> Joe Gregorio        http://bitworking.org
>


--
Mark Nottingham     http://www.mnot.net/
Received on Monday, 15 October 2007 06:58:45 GMT

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