- From: James M Snell <jasnell@gmail.com>
- Date: Thu, 08 Nov 2007 11:06:01 -0800
- To: Joe Gregorio <joe@bitworking.org>
- CC: URI <uri@w3.org>
Joe Gregorio wrote: > On 11/5/07, James M Snell <jasnell@gmail.com> wrote: >> Lastly, you had previously mentioned that the cardinality of vars with >> the join op was an issue. Could we not use +, * and ? for that? > > I think cardinality can be solved at a more > granular level by choosing between > listjoin and join. > > {-listjoin|&num=|numbers} > {-join|&|num} > Ok, so what I want to achieve is a url structure like: ?tag=tag1&tag=tag2&tag=tag3&start=0&count=10 Using listjoin and join, that would come out to: {-opt|?|tags,start,count}{-listjoin|&tag=|tags}{-opt|&|start,count}{-join|&|start,count} Alternatively, if we went with *, it would come out to: {-opt|?|tags,start,count}{-join|&|start,count,tag*} Both would work. The former is obviously more generalized than the second and the approach works well with other URL segments (like your gdata categories example). The latter is (in my opinion) more concise and readable. > What I do think can be done is indicate if a variable is optional or required. > Maybe append the variable name with '+' if the variable is required? > > {num+} // num is required > {-join|&|num,start-index,q+} // q is required, num and > start-index are optional > That works. > Note that setting a default value for a required element is > redundant, since if you don't supply a value the default will be > used. So this could probably be allowed, since it doesn't hurt > anything, but it doesn't add much: > > {num+=2} > > Allowing it keeps the parsing simple, as you don't have to add > a rule to forbid it. And this now allows you to neatly cover all the > cardinality cases you mentioned using a combination of > join, listjoin, and requiredness: > > {num} // 0 or 1 > {num+} // 1 > {-join|&|num} // 0 or more > {-join|&|num+} // 1 or more > wouldn't that be: {-join|&|num} // 0 or 1 {-join|&|num+} // 1 {-listjoin|&num=|nums} // 0 or more {-listjoin|&num=|nums+} // 1 or more Several more questions: * I assume that {-join|&|start,count} resolves to "start=foo&count=bar" and not "&start=foo&count=bar" (note the leading & in the latter). * I also assume that the ordering of the var's in the -join is insignificant? e.g. given {-join|&|start,count} the results "start=foo&count=bar" and "count=bar&start=foo" are equivalent and acceptable. * Given {-opt|?|tags,start,count}, the ? is inserted if at least one of the members of the set is defined. That is, if tags is defined but start and count are not, the ? will still be inserted. - James
Received on Thursday, 8 November 2007 19:06:25 UTC