W3C home > Mailing lists > Public > public-webapi@w3.org > May 2008

Re: [selectors-api] Proposal to Drop NSResolver from Selectors API v1

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Mon, 12 May 2008 20:00:06 +0200
Message-ID: <482885A6.7020200@lachy.id.au>
To: Maciej Stachowiak <mjs@apple.com>
Cc: Bjoern Hoehrmann <derhoermi@gmx.net>, public-webapi <public-webapi@w3.org>

Maciej Stachowiak wrote:
> On May 12, 2008, at 9:38 AM, Bjoern Hoehrmann wrote:
>> (There are other problems with using an object like the one you propose,
>> like being unable to specify a default namespace, unless you introduce
>> some kind of magic prefix representing the default namespace; ultimately
>> you don't gain much; you could also just accept a simple string in the
>> form "prefix1=ns1 prefix2=ns2 ..." like MSXML does for XPath, but there
>> isn't really a problem worth solving with the resolver function.)
> I'm convinced. I like the string better than my proposal. It removes the 
> need to specify anything regarding setters or other language bindings.

If I were to define that such a string should be used instead, would the 
following processing requirements work?

var ns = "http://www.w3.org/1999/xhtml svg=http://www.w3.org/2000/svg"
.querySelector("p svg|svg", ns);

Let ns be an empty hash map, where the key is the prefix and the value 
is the namespace uri.
Tokenise the nsresolver string by splitting on whitespace.
For each token:
   If there is an '=' character in the string:
     Split the string on the first '=' character
     Let prefix be the string before the '=' character
     Let uri be the string after the '=' character

   Otherwise, there is no '=' character:
     Let prefix be "" (the default namespace)
     Let uri be value of this token

   If ns[prefix] does not already exist:
     Let ns[prefix] = uri

Lachlan Hunt - Opera Software
Received on Monday, 12 May 2008 18:01:29 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:26 UTC