W3C home > Mailing lists > Public > uri@w3.org > September 2010

URI Template 04 Questions

From: Thomas Van Lenten <thomasvl@google.com>
Date: Mon, 27 Sep 2010 17:00:33 -0400
Message-ID: <AANLkTimuWh8v=aJD7v_pMJS4Ruiz2+20Xw5psadPoKtS@mail.gmail.com>
To: uri@w3.org
I've been working on an Objective-C implementation of the 04 draft,
and ran into some questions:

  - How should empty strings be handled when the expression has more
then one variable reference?  ('{x,empty,y}')
  - Section 2.3, paragraph 4 says an variable appearing more then once
should have the same value, what if a different default is listed in
both places?  ('X{foo=val1}Y{foo=val2}Z')
  - How should empty strings within arrays be handled? (list = ( 'a',
'', 'b' ) :: '{list}' or '{?list}')
  - How should empty strings as values in an associative array be
handled? ('keys'  = {'key1': 'val1', 'key2': '', 'key3': 'val3' } ::
'{keys}' or '{?keys}')
  - How should empty strings as keys in an associative array be
handled? ('keys'  = {'key1': 'val1', 'key2': 'val2', '': 'val3' } ::
'{keys}' or '{?keys}')

Following the style on the JSON tests in the Python implementation,
I've created a test file with some test cases for extra/exceptional
behaviors that are in the draft but weren't covered with examples.  I
also have a testcase at the end showing the first of the above
questions.

TVL
--
{
  "No varspec (section 3.3, paragraph 3)" :
  {
    "variables": {
       "var"   : "value"
     },
     "testcases" : [
        ["{}", "{}"],
        ["{,}", "{,}"],
        ["{,,}", "{,,}"]
     ]
  },
  "Missing closing brace (section 3.3 paragraph 4)" :
  {
    "variables": {
       "var"   : "value",
       "hello" : "Hello World!",
       "list"  : [ "val1", "val2", "val3" ],
       "keys"  : {"key1": "val1", "key2": "val2"},
       "x"     : "1024",
       "y"     : "768"
     },
     "testcases" : [
        ["{var", "value"],
        ["{hello", "Hello%20World%21"],
        ["{x,y", "1024,768"],
        ["{var=default", "value"],
        ["{undef=default", "default"],
        ["{list", "val1,val2,val3"],
        ["{list*", "val1,val2,val3"],
        ["{list+", "list.val1,list.val2,list.val3"],
        ["{keys", "key1,val1,key2,val2"],
        ["{keys*", "key1,val1,key2,val2"],
        ["{keys+", "keys.key1,val1,keys.key2,val2"]
     ]
  },
  "varspec of only operator and explodes (section 3.3?)" :
  {
    "variables": {
       "var"   : "value"
     },
     "testcases" : [
        ["{+}", "{+}"],
        ["{;}", "{;}"],
        ["{?}", "{?}"],
        ["{/}", "{/}"],
        ["{.}", "{.}"],
        ["{+,}", "{+,}"],
        ["{;,}", "{;,}"],
        ["{?,}", "{?,}"],
        ["{/,}", "{/,}"],
        ["{.,}", "{.,}"],
        ["{++}", "{++}"],
        ["{;+}", "{;+}"],
        ["{?+}", "{?+}"],
        ["{/+}", "{/+}"],
        ["{.+}", "{.+}"],
        ["{+*}", "{+*}"],
        ["{;*}", "{;*}"],
        ["{?*}", "{?*}"],
        ["{/*}", "{/*}"],
        ["{.*}", "{.*}"]
     ]
  },
  "One good varspec and bad varspecs (section 3.3, paragraph 3?)" :
  {
    "variables": {
       "var"   : "value"
     },
     "testcases" : [
        ["{var,}", "value"],
        ["{,var}", "value"],
        ["{,var,,}", "value"],
        ["{+var,,}", "value"],
        ["{;var,,}", ";var=value"],
        ["{?var,,}", "?var=value"],
        ["{/var,,}", "/value"],
        ["{.var,,}", ".value"],
        ["{+,var,}", "value"],
        ["{;,var,}", ";var=value"],
        ["{?,var,}", "?var=value"],
        ["{/,var,}", "/value"],
        ["{.,var,}", ".value"],
        ["{+,,var}", "value"],
        ["{;,,var}", ";var=value"],
        ["{?,,var}", "?var=value"],
        ["{/,,var}", "/value"],
        ["{.,,var}", ".value"]
     ]
  },
  "Multiple undefined variables (section 3.4)" :
  {
    "variables": {
       "var"   : "value"
     },
     "testcases" : [
        ["{undef1,undef2}", ""],
        ["{+undef1,undef2}", ""],
        ["{;undef1,undef2}", ""],
        ["{?undef1,undef2}", ""],
        ["{/undef1,undef2}", ""],
        ["{.undef1,undef2}", ""]
     ]
  },
  "Default with variable in varspec (just reported like above cases)" :
  {
    "variables": {
       "var"   : "value"
     },
     "testcases" : [
        ["{=foo}", "{=foo}"]
     ]
  },
  "varspec with bad partial (partial gets ignored)" :
  {
    "variables": {
       "var"   : "value"
     },
     "testcases" : [
        ["{var:}", "value"],
        ["{var^}", "value"]
     ]
  },
  "Default of empty string and edge cases with empty strings" :
  {
    "variables": {
       "empty" : "",
       "x"     : "1024",
       "y"     : "768"
     },
     "testcases" : [
        ["{empty}", ""],
        ["{;x,empty,y}", ";x=1024;empty;y=768"],
        ["{?x,empty,y}", "?x=1024&empty&y=768"],
        ["{x,empty,y}", "1024,,768"],
        ["{+x,empty,y}", "1024,,768"],
        ["{/x,empty,y}", "/1024//768"],
        ["{.x,empty,y}", ".1024..768"],
        ["{undef=}", ""],
        ["{;x,undef=,y}", ";x=1024;undef;y=768"],
        ["{?x,undef=,y}", "?x=1024&undef&y=768"],
        ["{x,undef=,y}", "1024,,768"],
        ["{+x,undef=,y}", "1024,,768"],
        ["{/x,undef=,y}", "/1024//768"],
        ["{.x,undef=,y}", ".1024..768"]
     ]
  }
}
Received on Monday, 27 September 2010 21:01:03 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:25:14 UTC