extracting namespace from a property

Yuh-Ruey Chen maian330 at gmail.com
Sun Feb 4 22:15:13 PST 2007


Is there any standard way to ascertain whether a property of a non-XML
object is qualified by a namespace? This can be useful when enumerating
over an object. I've looked at chapters 4 (fundamental concepts), 12
(namespaces), 14 (expressions), and 19 (native objects) and didn't find
a clear answer.

In chapter 4, both readReference and writeReference delegate the
responsibility of actually reading/setting values in
traits.intrinsic::read and traits.intrinsic::write, respectively. Both
of those are not defined anywhere, so I don't know how QNames are stored
as properties.

In JS1.7, |obj.ns::prop| is equivalent to |obj['ns_uri::prop']| where
ns's URI is 'ns_uri'. That allows something like this:

for (let qk in o1) {
    let ns_uri, k;
    let t = qk.split('::');
    if (t.length == 1) {
        k = t[0];
    } else {
        [ns_uri, k] = t;
    }
    print(ns_uri + '::' + k);
}

Not only is this possibly non-standard, it's cumbersome and does not get
the actual Namespace object.

Chapter 12 doesn't mention this issue at all.

Chapter 14 has production rules for qualifiers, but the evaluation of
them makes use of internal functions and the internal Name datatype from
chapter 4.

Chapter 19 doesn't mention this issue at all.

The meta-objects proposal has namespace() has a method of NominalType,
but properties aren't types.

-Yuh-Ruey



More information about the Es4-discuss mailing list