473,513 Members | 2,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

E4X: can't use "delete" with filter

This problem shows up in Firefox 1.5.0.1 and Rhino 1.6R2.

I've found that if I have an XML node expression that ends in a filter,
I can't use it with the delete operator. In the following example, the
delete operation has no effect:

var z = <abc><foo a='1'>1</foo><foo a='2'>2</foo></abc>;
alert(z.foo.(@a == '2'));
delete z.foo.(@a == '2');

even though the expression is valid. I've come up with the following
grim-looking workaround:

function deleteNodes(node, expr) {
for each (i in eval('node.' + expr)) {
eval('delete node.' + expr + '[0]');
}
}

var z = <abc><foo a='1'>1</foo><foo a='2'>2</foo></abc>;
deleteNodes(z, "foo.(@a == '2')");

which does what I want.

Is this by design? It's really annoying that I can't use delete this
way. The problem shows up in Firefox 1.5.0.1 and Rhino 1.6R2. I've
found that if I have an XML node expression that ends in a filter,
I can't use it with the delete operator. In the following example, the
delete operation has no effect:

var z = <abc><foo a='1'>1</foo><foo a='2'>2</foo></abc>;
alert(z.foo.(@a == '2'));
delete z.foo.(@a == '2');

even though the expression is valid. I've come up with the following
grim-looking workaround:

function deleteNodes(node, expr) {
for each (i in eval('node.' + expr)) {
eval('delete node.' + expr + '[0]');
}
}

var z = <abc><foo a='1'>1</foo><foo a='2'>2</foo></abc>;
deleteNodes(z, "foo.(@a == '2')");

which does what I want.

Is this by design? It's really annoying that I can't use delete this
way. The problem shows up in Firefox 1.5.0.1 and Rhino 1.6R2.

Mar 14 '06 #1
2 2021
VK

Bob Tinsman wrote:
This problem shows up in Firefox 1.5.0.1 and Rhino 1.6R2.

I've found that if I have an XML node expression that ends in a filter,
I can't use it with the delete operator. In the following example, the
delete operation has no effect:

var z = <abc><foo a='1'>1</foo><foo a='2'>2</foo></abc>;
alert(z.foo.(@a == '2'));
delete z.foo.(@a == '2');

even though the expression is valid. I've come up with the following
grim-looking workaround:

function deleteNodes(node, expr) {
for each (i in eval('node.' + expr)) {
eval('delete node.' + expr + '[0]');
}
}

var z = <abc><foo a='1'>1</foo><foo a='2'>2</foo></abc>;
deleteNodes(z, "foo.(@a == '2')");

which does what I want.

Is this by design? It's really annoying that I can't use delete this
way. The problem shows up in Firefox 1.5.0.1 and Rhino 1.6R2. I've
found that if I have an XML node expression that ends in a filter,
I can't use it with the delete operator. In the following example, the
delete operation has no effect:

var z = <abc><foo a='1'>1</foo><foo a='2'>2</foo></abc>;
alert(z.foo.(@a == '2'));
delete z.foo.(@a == '2');

even though the expression is valid. I've come up with the following
grim-looking workaround:

function deleteNodes(node, expr) {
for each (i in eval('node.' + expr)) {
eval('delete node.' + expr + '[0]');
}
}

var z = <abc><foo a='1'>1</foo><foo a='2'>2</foo></abc>;
deleteNodes(z, "foo.(@a == '2')");

which does what I want.

Is this by design? It's really annoying that I can't use delete this
way. The problem shows up in Firefox 1.5.0.1 and Rhino 1.6R2.


Congratulations: you are the first person in the history of this group
who's trying to use this new stuff :-)

Not extremely helpful but:
1) E4X is only *partially* implemented in latest Gecko.
2) To fully enable all implemented parts (which is still not full E4X)
use
<script type="text/javascript;e4x=1">
3) AFAICT Mozilla does everything literally as spelled in ECMA, so
reading
<http://www.ecma-international.org/publications/standards/Ecma-357.htm>
may be helpful.
4) I guess bugzilla.mozilla.org is currently being filled up by freshly
discovered E4X bugs. By searching "E4X" you may get some immediate
answers.

My lack of E4X knowledge doesn't allow to answer to your direct
question. Hopefully someone can be more useful.

Mar 15 '06 #2


Bob Tinsman wrote:

I've found that if I have an XML node expression that ends in a filter,
I can't use it with the delete operator.


Does this example approach

var gods = <gods><god name="Kibo" /><god name="Jaffo" /><god name="Xibo"
/></gods>;
for each (var god in gods.god.(@name.indexOf('ibo') != -1)) {
delete gods.god[god.childIndex()];
}

help?

That way you iterate over the XML objects the filter finds and then
delete them.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1717
by: Stefan Strasser | last post by:
why is delete an expression and not a statement? (in my draft copy of the standard). I was about to ask the same question about "throw" but found an expression case of throw("return boolvalue ? 5...
13
3080
by: gary | last post by:
Hi, We all know the below codes are dangerous: { int *p = new int; delete p; delete p; } And we also know the compilers do not delete p if p==NULL. So why compilers do not "p = NULL"...
8
25029
by: John Baker | last post by:
Hi: Access 2000 W98! I have a table with numerous records in it, and am attempting to delete certain records that have been selected from it. These are selected based on the ID number in a...
1
1365
by: Michael Ramey | last post by:
Hi, I'm dynamically creating a table of "delete" imagebuttons, that correspond to files on the webserver. I want to respond to clicks of these buttons, so I know to know what file to delete. ...
5
8068
by: mkaushik | last post by:
Hi everyone, Im just starting out with C++, and am curious to know how "delete <pointer>", knows about the number of memory locations to free. I read somewhere that delete frees up space...
0
985
by: Terry Olsen | last post by:
I need to delete files from "C:\WINNT\Downloaded Program Files" I can delete them using Windows Explorer, but they do not appear in the command prompt directory listing. How can I delete these...
19
10728
by: Daniel Pitts | last post by:
I have std::vector<Base *bases; I'd like to do something like: std::for_each(bases.begin(), bases.end(), operator delete); Is it possible without writing an adapter? Is there a better way? Is...
30
3788
by: Medvedev | last post by:
i see serveral source codes , and i found they almost only use "new" and "delete" keywords to make they object. Why should i do that , and as i know the object is going to be destroy by itself at...
3
35565
by: tvnaidu | last post by:
I compiled tinyxml files (.cpp files) and when I am linking to create final exe in Linux, I am getting lot of errors saying "undefiend reference" to "operator new" and "delete", any idea?. ...
0
7265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7545
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7539
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5692
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5095
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.