Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > E4X/Firefox 1.5: problem using default xml namespace

Reply
Thread Tools

E4X/Firefox 1.5: problem using default xml namespace

 
 
Bob Tinsman
Guest
Posts: n/a
 
      03-14-2006
I've been interested in E4X because my company has an XML schema that
we usually manipulate through a Java mapping generated by Castor, which
I think is fairly tedious, and which means you have to do everything in
the webapp. I think it'd be cool to suck in the XML, tweak it in the
browser, then use a SOAP call to submit it to the server.

Anyhow, we use namespaces on all our elements, and I was trying to
avoid using the "ns::elementname" notation if I didn't have to. I
thought that calling "default xml namespace = 'our.namespace'" would
let us do that. In other words, I could do something like this:

var a = <n:abc
xmlns:n="urn:something"><n:foo>1</n:foo><n:foo>2</n:foo></n:abc>;
default xml namespace = "urn:something";
alert(a.foo);

However, running that inside a function in a web page returns an empty
string. But the following:

alert(eval("a.foo"));

returns what I expect, which is this:

<n:foo xmlns:n="urn:something">1</n:foo>
<n:foo xmlns:n="urn:something">2</n:foo>

I tried an example with both of these:

alert(a.foo);
alert(eval("a.foo"));

But if they are in the same method, "a.foo" returns the same thing as
"eval('a.foo')", which is mighty strange. Even if I do:
alert(a.foo);
eval("");

I get it to work. That tells me there is something about the parsing of
the expression that is going awry, but the presence of the eval("")
makes it work OK.

My Mozilla version is: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1

I tried Rhino 1.6R2 and I get the behavior I expect, with the eval or
not.

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      03-15-2006


Bob Tinsman wrote:

> var a = <n:abc
> xmlns:n="urn:something"><n:foo>1</n:foo><n:foo>2</n:foo></n:abc>;
> default xml namespace = "urn:something";
> alert(a.foo);


The problem seems only to occur if that code is executed in function
scope. Nevertheless it is a bug in my understanding so I have filed a
bug report
<https://bugzilla.mozilla.org/show_bug.cgi?id=330572>


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default-default namespace and localname Max XML 2 08-01-2006 04:17 PM
using namespace available outisde namespace Andrew Ward C++ 5 07-25-2005 06:32 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
Is 'using namespace std;' valid without 'namespace std {};' first? Petter Reinholdtsen C++ 9 11-29-2004 03:28 PM
Reaching into the default namespace when using another namespace. Jason Heyes C++ 1 11-19-2004 02:36 AM



Advertisments