RE: [rest-discuss] URI Templates & Patterns

Steve G. Bjorg wrote:
> I'm looking for some feedback on URI patterns.  I just 
> recently found out about URI templates [1] and have been 
> scratching my head on how they could be extended to also 
> provide URI patterns.

FYI, the list to discuss URI Templates is [uri@w3.org].  URI Templates is a
great piece of work.

> For example:
> http://server/{first}/{last}
> 
> This URI could be used to produce or consume a URI such as:
> http://server/john/doe
> 
> However, the template syntax doesn't work for matching query 
> parameters:
> http://server/{first}/{last}?maxcount={maxrecords}&offset={offset}
> 
> In this case, producing an URI is simple, but for using it as 
> a pattern, a few questions arise:
> * How would one indicate that 'maxcount' and 'offset' are 
> optional parameters?
> * How would one indicate that they are mandatory?
>
> How about using brackets to identify optional parameters?
> http://server/{first}/{last}?[maxcount={maxrecords}]&offset={offset}
> 
> Would it make sense to combine them?  For example to indicate 
> that both parameters are needed or neither?
> http://server/{first}/{last}?[maxcount={maxrecords}&offset={offset}]

I'm pretty sure the syntax for option is a trailing question mark within the
braces, i.e.:

	http://server/{first}/{last}?maxcount={maxrecords?}&offset={offset?}

The idea here is that if maxrecords is null then all of
"maxcount={maxrecords?}" would be omitted  and same for offset  (I think. I
hope.)   

> 
> How about either/or choices using vertical bar (|)?
>
http://server/{first}/{last}?[maxcount={maxrecords}&[offset={offset}|page={p
age}]]
> 

I had proposed a comma, but since I proposed it occurred to me that a
vertical bar would be more consistent with other languages use of an "or"
operator so to me, yes it makes sense.

That said, I cc'd [uri@w3.org]; you can review the archive and sign up at
[1].

-- 
-Mike Schinkel
http://www.mikeschinkel.com/blogs/
http://www.welldesignedurls.org/
"It never ceases to amaze how many people will proactively debate away
attempts to improve the web..."

[1] http://lists.w3.org/Archives/Public/uri/

Received on Tuesday, 16 January 2007 02:08:21 UTC