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

On Thu, Mar 11, 2010 at 7:55 AM, Jacob Beard <[email protected]> wrote:
> 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
>
> On Sat, Mar 6, 2010 at 9:37 AM, Martin Blom <[email protected]> wrote:
>>
>> 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 --------------------------- [email protected] ----
>> Eccl 1:18                                 http://martin.blom.org/
>>
>>
>>
>> _______________________________________________
>> dev-tech-js-engine-rhino mailing list
>> [email protected]
>> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>>
>>
>
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to