Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

referring to the "context node" in XML filtering predicate with E4X

18 views
Skip to first unread message

Martin Honnen

unread,
Apr 1, 2005, 12:03:05 PM4/1/05
to

E4X section 11.2.4 describes the XML filtering predicate operator. In
the predicate I would like to call a method of the XML object the
filtering predicate is applied to e.g.
xmlObject..*.(nodeKind() == 'text')
however both Rhino and Spidermonkey then tell me that nodeKind is not
defined. Is there any way to call a method in the predicate or is the
predicate only able to access non function properties (i.e. the child
elements by name or the attributes by @attributename)?


--

Martin Honnen
http://JavaScript.FAQTs.com/

Brendan Eich

unread,
Apr 2, 2005, 1:44:13 AM4/2/05
to Martin...@gmx.de


E4X has what I call a bug where method names are hidden from the normal
property lookup mechanism, even though the spec says they're
function-valued properties of XML.prototype and XMLList.prototype. We
are talking about fixing this with a function namespace.

I've prototyped this in SpiderMonkey such that (with a fix just checked
in today) the following works:

$ cat fn.js

xmlObject = <a><b>hi</b><b>there</b></a>

l = xmlObject..*.(function::nodeKind() == 'text' &&
print(function::toXMLString()))

$ Linux_All_DBG.OBJ/js -x fn.js
hi
there

The function reserved identifier, when used as a namespace prefix,
identifies an internal namespace whose URI is guaranteed not to collide
with any valid URI. This namespace allows qualified access to function
valued properties of XML.prototype (i.e., methods).

/be

0 new messages