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

RE: Alternative URL template proposal

From: Manger, James H <James.H.Manger@team.telstra.com>
Date: Mon, 12 Nov 2007 14:58:41 +1100
Message-ID: <6215401E01247448A306C54F499111F203787DE4@WSMSG2103V.srv.dir.telstra.com>
To: <uri@w3.org>
I agree with the general thrust of DeWitt Clinton’s proposal (simpler syntax, instead of (possibly) extensible operators). But…

Appending “?” to indicate zero or one is unnecessary. If a name=value parameter is REQUIRED then include the “name=” portion outside the braces.
Instead of:  http://example.com{?q=searchTerms,n=startIndex?}

Use:         http://example.com?q={searchTerms}{(&n=)startIndex}
Similarly, appending “+” to indicate one or more is unnecessary. “{(prefix)var+(sep)}” can produce an identical set of URIs to “prefix{var*(sep)}”.
Instead of:  http://example.com{(/-/)categories+/}
Use:         http://example.com/-/{categories*/}

[Though the same set of URIs can be defined with “+” or “*”, software could trigger an error if a variable with “+” was not defined. This is a very minor advantage.]

“&” may be worse than “,” in XML (error-prone, less legible, longer) -- but it is too late.
URIs use ampersands. URI templates will often use ampersands outside the braces. Trying to avoid them inside the braces just makes URI templates look, feel and behave less like URIs -- which is a bad thing.

I prefer {count=} to {=count} when the key and variable name match. The difference is trivial, but the former looks like a valid URI plus braces.
Instead of:  http://example.com/feed?{=count}

Use:         http://example.com/feed?{count=}

Supporting lists of variables in a single pair of braces is unnecessary. Using separate braces for each variable can achieve the same semantics and makes the template look much more like the URIs that can be generated -- which is a good thing.
A list allows a prefix for the whole collection, but this can be solved with a small amount of logic in the processor. Recognize “?name=” and “&name=” as query string parts and use “?” or “&” as appropriate.
A list may save 3 characters per variable (“,x” instead of “{&x=}”), but that is a very minor benefit.
Note: A list of variables is different from a single variable that has a list of values.
Instead of:  http://example.com/find{?=start,=count,=tag}

Use:         http://example.com/find{?start=}{&count=}{&tag=}

Received on Monday, 12 November 2007 03:59:04 UTC

This archive was generated by hypermail 2.4.0 : Sunday, 10 October 2021 22:17:50 UTC