473,667 Members | 2,562 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(nod e, 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(nod e, 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 2042
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(nod e, 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(nod e, 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.o rg/publications/standards/Ecma-357.htm>
may be helpful.
4) I guess bugzilla.mozill a.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
1722
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 : throw 5;"). but "delete" neither does exit the scope nor has a return value. any idea? thanks,
13
3097
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" automatically after programs do "delete p"?
8
25055
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 different table. While I am using the tools in Access for query setup, its easier to show it on here using the SQL for the query, which is as follows( the table is ): DELETE .date, .,
1
1373
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. Here is the code I'm using Dim imgShow As New ImageButton imgShow.CommandName = "Delete" imgShow.CommandArgument = arrayOfFiles(i) AddHandler imgShow.Command, AddressOf Image_Command
5
8078
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 assigned to <pointerby "new". Does "new" create a list of pointer names and the size of the memory array they point to? I also read that some compilers may store the number of consec mem locations a pointer points to, just before the first data...
0
992
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 items using VB? *** Sent via Developersdex http://www.developersdex.com ***
19
10744
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 there an existing adapter? Thanks, Daniel.
30
3811
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 the end of the app for example: class test { public: int x;
3
35799
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?. Main.cpp:377: undefined reference to `operator delete(void*)' tinyXML/include/tinystr.h:259: undefined reference to `operator delete(void*)' ../common/tinyXML/include/tinyxml.h:1401: undefined reference to `operator delete(void*)'...
0
8457
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8883
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8788
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8563
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8646
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7390
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2013
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.