by Danny Patterson on March 30th, 2010
I recently came accross an odd behavior when adding namespaces to an attrubute using E4X. I needed to create an XML object like the following:
1
| <body xml:lang="en" xmpp:version="1.0" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xmpp="urn:xmpp:xbosh" /> |
This XML element is created dynamically within the ActionScript code like this:
1
2
3
4
5
| var body:XML = <body />;
var xml:Namespace = new Namespace("xml", "http://www.w3.org/XML/1998/namespace");
body.@xml::lang = "en";
var xmpp:Namespace = new Namespace("xmpp", "urn:xmpp:xbosh");
body.@xmpp::version = "1.0"; |
However, the output of the namespaces in the XML was off:
1
| <body aaa:lang="en" aab:version="1.0" xmlns:aaa="http://www.w3.org/XML/1998/namespace" xmlns:aab="urn:xmpp:xbosh" /> |
I realize this is still valid, but the server was having issues with it. That’s when I discovered that I need to first add the namespaces to the XML element using addNamespace(). This then gave me the right output:
1
2
3
4
5
6
7
| var body:XML = <body />;
var xml:Namespace = new Namespace("xml", "http://www.w3.org/XML/1998/namespace");
body.addNamespace(xml);
body.@xml::lang = "en";
var xmpp:Namespace = new Namespace("xmpp", "urn:xmpp:xbosh");
body.addNamespace(xmpp);
body.@xmpp::version = "1.0"; |
Hopefully this will save someone else an hour of banging his or her head against the wall.
by Danny Patterson on May 23rd, 2007
I’m once again speaking at FlashBelt this year. I’ll be speaking on the topic of E4X, the new technology for working with XML in ActionScript 3. I gave a talk on XML at FlashBelt a few years ago and talked a bit about the future of XML in ActionScript including E4X. Well, that future is finally here.
Patterson Consulting is also a development sponsor of FlashBelt this year. Its a great conference and I’m glad to be able to participate. See ya there!
by Danny Patterson on September 5th, 2005
I published a new article over at Community MX last week on how to create an XML configuration file for you Flash application. Check it out here.
by Danny Patterson on July 22nd, 2005
I just published a review of a great tool from Altova called XMLSpy. If you are a developer that uses XML, you should really check this product out. The review is focused on three main features that I use in my ColdFusion and ActionScript development. You can view the article here. BTW the article is free. ;)
by Danny Patterson on July 1st, 2005
Google just released its XSLT and XPath JavaScript code under the title AJAXSLT. The code is supposed to be a full implementation of XSLT, and therefore XPath. Thank you Google!
by Danny Patterson on June 17th, 2005
I just got done speaking at the FlashBelt conference this week in Minneapolis. It was a great conference and it was exciting to see how strong the Flash community is in this area.
As promised, I have posted my presentation on XML in Flash. I hope everyone got something useful out of it.
by Danny Patterson on May 3rd, 2005
I have a new article that was recently published at Community MX titled Use XML to Populate Dependant Select Lists.
“Nearly everyone has seen the classic Dependant Select Lists. It’s a great user interface technique where you have two or more select form elements and the selection of one list changes the contents of the next list. This is commonly done with City and State selection interfaces. This tutorial will demonstrate how to build Dependant Select Lists and populate the lists using an XML data file.”
by Danny Patterson on December 14th, 2004
I have a new article at Community MX that covers how you can use XSLT with ColdFusion and ASP.NET.
The article covers the creation of the XSLT document and code samples for performing a server-side transformation in either ColdFusion or ASP.NET.
by Danny Patterson on August 27th, 2004
Check out my newest article at Community MX on using the XFactorStudio AS2 XPath classes.
by Danny Patterson on June 3rd, 2004
I have used XPath many times and I love its functionality. That is why I was so thrilled when I ran accross this resource. XFactor Studio has developed a series of XPath AS2 classes for Flash MX 2004. These classes are nearly a complete 1.0 implementation of the XPath specification. I also noticed that they are currently developing an upgrade that would be a complete implementation.