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

E4X filter scope

82 views
Skip to first unread message

Martin Blom

unread,
Mar 6, 2010, 9:37:28 AM3/6/10
to Rhino List JS User

It's my understanding from ECMA-375, 2nd edition, section 11.2.4, that
given

xml = <xml><e id="1"/><e id="2"/></xml>;

the following code

xml.*.(@id == "1")

(which returns the <e id="1"/> element) could also be written as

xml.*.(attribute("id") == "1")

I.e., not only the node's properties but also its methods should be
available to the filters. However, this is not the case in Rhino. It
does work in Flex/ActionScript, but not in Firefox, which, however,
allows the following odd syntax:

xml.*.(function::attribute("id") == "1")

Now, comparing XMLWithScope.java with NativeWith.java, one finds that
the latter not only calls setPrototype() but also setParentScope(),
which XMLWithScope does not. If one applies the following patch, the
attribute() example works as expected:

---
rhino-7r2-commonjs-3rd/xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLWithScope.java
2008-04-13 12:24:46.000000000 +0200
+++
rhino-7r2-lcs/xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLWithScope.java
2010-03-02 22:59:36.503843503 +0100
@@ -75,6 +75,7 @@
XMLList xl = (XMLList)prototype;
if (xl.length() > 0) {
setPrototype((Scriptable)(xl.get(0, null)));
+ setParentScope(getPrototype());
}
}
// Always return the outer-most type of XML lValue of
@@ -109,6 +110,7 @@
// the WITH selector.
_currIndex = idx;
setPrototype((Scriptable)(orgXmlL.get(idx, null)));
+ setParentScope(getPrototype());

// continue looping
return null;

Is this the correct solution, and if so, could we have it added to CVS?

--
---- Martin Blom --------------------------- mar...@blom.org ----
Eccl 1:18 http://martin.blom.org/


Jacob Beard

unread,
Mar 11, 2010, 7:55:11 AM3/11/10
to Rhino List JS User
Martin, from another user, thank you for reporting this. I spent
several hours last night looking at the specification and ActionScript
examples, trying to understand how and why the Rhino implementation
was not working. It's good to see I'm not the only one with this
problem, as for me, it seems to make certain queries impossible.

For example, I've been working with SCXML, and I would like to get all
of the "basic states". These are state elements that do not have any
state elements in their descendants. I believe I would issue this
query as follows:

xml..states.(descendants().states.length() == 0)

But, this fails due to the issue you described. It's not clear to me
if there is a way to work around this issue, or if there is an
alternative way of expressing the above query such that is not blocked
by the issue.

Also, have you opened a bug report for this? Bugzilla might be be the
best place to put some of this information.

Thanks,

Jake

> _______________________________________________
> dev-tech-js-engine-rhino mailing list
> dev-tech-js-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>
>

Jacob Beard

unread,
Mar 11, 2010, 8:04:54 PM3/11/10
to Rhino List JS User
Hi,

I filed a bug report for this. Sorry, Martin, but I plagiarized you a bit.

https://bugzilla.mozilla.org/show_bug.cgi?id=551854

I would really like to see this bug get fixed. Until that happens,
I'll need to use XPath :(

Jake

Martin Blom

unread,
Mar 12, 2010, 1:59:11 PM3/12/10
to Jacob Beard, Rhino List JS User
On 12/03/2010 02:04, Jacob Beard wrote:
> Hi,
>
> I filed a bug report for this. Sorry, Martin, but I plagiarized you a bit.
>
> https://bugzilla.mozilla.org/show_bug.cgi?id=551854
>
> I would really like to see this bug get fixed. Until that happens,
> I'll need to use XPath :(

Thanks, Jake :-)

P

unread,
Feb 14, 2013, 4:17:20 AM2/14/13
to Jacob Beard, Rhino List JS User
I see an altered patch on the bug report. Any change to get this applied to the codebase?

P.

Op vrijdag 12 maart 2010 19:59:11 UTC+1 schreef Martin Blom het volgende:

pba...@servoy.com

unread,
Jul 17, 2013, 5:18:18 AM7/17/13
to
FYI: we applied it to our version of Rhino and have it up and running in production without issues

Op donderdag 14 februari 2013 10:17:20 UTC+1 schreef P het volgende:
0 new messages