- From: John Kemp <john@jkemp.net>
- Date: Tue, 23 Oct 2007 17:21:19 -0400
- To: Marc Hadley <Marc.Hadley@Sun.COM>
- CC: URI <uri@w3.org>
Hi Marc,
Marc Hadley wrote:
> On Oct 22, 2007, at 11:45 AM, John Kemp wrote:
>>
>> I have written some simple C code to process and match URI
>> templates against URIs. I'm using the "va_list" approach to create
>> a C function that takes a URI template (as a string) and a
>> variable-length list of string values to put into the template,
>> creating a URI with all substitutions made.
>>
>> I can't tell from the specification whether this is a good idea ;)
>>
> I think there's a place for positional substitutions, the current
> JAX-RS UriBuilder has support for both positional and named variables
> in the build methods:
>
> https://jsr311.dev.java.net/nonav/javadoc/javax/ws/rs/core/UriBuilder.html
>
OK.
>
>> But, for this usage, I don't really need named variables. I could
>> certainly choose to use distinct variable names anyway, and
>> essentially discard them during the substitution, but my usage
>> seems a little similar to the idea of backreferences in regular
>> expressions, and I was wondering whether it makes any sense to
>> standardize a variable name for when the name is not important, or
>> for a specific ordering of values?
>>
> Even if we allowed anonymous variables I'm not sure the specification
> would be the right place to define default names. Seems to me like
> that is something that a URI template library could do itself.
Yes, that's certainly possible.
> What's your use case for a default name ?
Well, I have more or less the same usage as your Java method:
> public abstract java.net.URI build(java.lang.String... values) throws
> java.lang.IllegalArgumentException, UriBuilderException
Except, instead of using the variable name even in positional
substitutions, my usage is even simpler. In other words, in your example:
> All instances of the same template parameter will be replaced by the
> same value that corresponds to the position of the first instance of
> the template parameter. e.g. the template "{a}/{b}/{a}" with values
> {"x", "y", "z"} will result in the the URI "x/y/x", not "x/y/z".
My code would result in your latter case - x/y/z, rather than the
former, as I completely ignore the variable names themselves. As I said,
I'm not convinced that what I do is actually a good idea yet, but
certainly, there is no need for variable names to be supplied in this
usage. The specification, as is, supports that, and as you mention I can
choose a convention for my own code processing my own URI templates.
I did wonder though whether it would make sense to choose a standard
name value to indicate that a variable is there, but to denote that the
name itself is not relevant. Using {} wouldn't meet the spec (today).
- John
>
> Cheers, Marc.
>
> --- Marc Hadley <marc.hadley at sun.com> CTO Office, Sun
> Microsystems.
>
>
Received on Tuesday, 23 October 2007 21:21:31 UTC