Alright, I've read the specs, it's not a bug but in fact it's by design... a design choice that I would not have made. The deal is if the namespace is not specified then for elements it matches on the default namespace, but for attributes it matches on no namespace... makes not sense to me. What also doesn't make sense is that attributes don't have a namespace unless declared per attribute. They do not inherit from the element, which is what XML Schema defines, but since Schema really doesn't come into play here this can be expected.
It's all totally bizzare. Paul Paul deCoursey wrote: > I have been getting caught up with with one for a few weeks now, I keep > forgetting to specify the namespace. I actually think this is a bug, > but I haven't checked the Ecma requirements yet. In XPATH and the like > if you don't specify a namespace in the query it will return all > elements regardless of namespace. This only seems to be an issue in the > ecma world, and it seems wrong to me. I suppose it could be argued that > this helps us be better programmers and specifying namespaces is better > in the long run. But in the example that you guys were working with it > was the xml namespace, that should just be handled... just my opinion, > but a lot of time was wasted on this and in my opinion it's a bug, > possibly a language level "bug". > > Paul > > Seth Caldwell wrote: > >> Oh my god Toby, I just spent an hour because I was determined to learn about >> namespaces, and found a solution for you. =) >> >> After reading >> http://www.partlyhuman.com/blog/roger/using-e4x-with-xhtml-watch-your-namespaces >> >> >> >> I created blah.xml >> >> <test xmlns:b="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><a >> b:c="d">bleh</a><a b:c="e">blah</a></test> >> >> Then loaded it with <mx:XML source="blah.xml" id="tx" format="e4x" /> >> >> >> >> Then ran this: >> >> mx.controls.Alert.show("value is: " +tx.a.(attributes()[0]=="d")); >> >> which alerted “value is: bleh”. >> >> >> >> We could also do this: >> >> mx.controls.Alert.show("value is: " +tx.a.(@*::c=="d")); >> >> >> >> Oh my god, right? So I put your original XML into blah.xml, then did this: >> >> mx.controls.Alert.show("value is: " >> +tx.*::Status.*::presence.(@*::lang=="en")); >> >> >> >> Guess what?! “value is: Away”!! >> >> >> >> We win. >> >> Change this code >> >> >> >> for (i=0; i < event.result.RDF.Status.presence.length; i++) { >> if(event.result.RDF.Status.presence[i]["xml:lang"] == "en") >> if(event.result.RDF.Status.presence[i]["value"] != "Offline") >> status = "Online"; >> >> >> >> to this code >> >> >> >> if(event.result.RDF.*::Status.*::presence.(@*::lang==”en”)==”Offline”) >> status = “Online”; >> >> >> >> wewt, >> >> >> >> Seth >> >> >> >> > > >

