# Thursday, 17 March 2005

Here we are in the year 2005.  XML has been pretty ubiquitous for at least 5–6 years now.  Namespaces have been in use for pretty much all of that time.  And yet they remain possibly the least understood part of average, everyday XML processing. 

The bottom line is that pretty much any XML parser worth its salt these days supports the namespaces spec.  Which means that

<MyElement/>

is absolutely not the same thing as

<MyElement xmlns=”urn:runforthehills”/>

Furthermore, in line with the XML Namespaces spec, an application which is expecting the latter, namespace qualified element should not and must not process the former, unqualified element.

The XmlSerializer that we all know and love in .NET is particularly sensitive to this issue (as well it should be).  As far as the serializer is concerned, everything should be namespace qualified.  The way this commonly bites people is thus: a customer/partner sends you a schema representing the XML documents they are going to be sending you.  In the schema, the targetNamespace attribute is set with a value of “http://partner.com/schema”.  When you actually do to debug the application however, it turns out they are sending you totally unqualified XML.  Nothing will work.  There are a few pretty horrible things you can do with the XmlSerializer to try and convince it not to be such a stickler about things, most involving the XmlRootAttribute and XmlAttributeOverrides.  I can share those ways if anyone really wants to see them.  Probably best to keep them under cover.  However, that’s only likely to work if your XML document is flat, meaning that the root element only has one level of child nodes under it.  Otherwise, if you use Xsd.exe to generate your serialization class, each set of sub elements get put in their own object, which will also be namespace qualified.  And you’re back to square one. 

The right solution of course is to get your partner to send you XML that’s actually correct, but often that’s just not possible for a variety of reasons with which I’m sure we’re all familiar.  As a last ditch effort, you can pre-process the XML text before passing it to the XmlSerializer, and inject the right namespace strings.  Yucky, it’s true, but it does actually get the job done.  You will of course, be paying some overhead costs of string processing and possibly parsing the XML twice.  But what can you do?

The other thing to keep in mind is how namespaces play out in XSD schema files.  You can only have one target namespace per schema, so anything you define in that schema file will be in that target namespace.  You can import things from other namespaces, but not from the target namespace.  You can, however, define two different schema files that use the same namespace, then import them both into another schema, as long as there are no name collisions.  If you omit the targetNamespace attribute from your schema, the targetNamespace becomes “”, meaning you are defining the schema for an unqualified XML document. 

Confusing enough?  Read the namespace spec (it’s really short), familiarize yourself with how namespaces work in schema, if you see errors coming back from the XmlSerializer that look like

The element <spam xmlns=””> was not expected.

check your namespaces!  That means you are trying to deserialize an unqualified document, when a qualified one was expected.

Thursday, 17 March 2005 13:00:03 (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
Scott and Rory have another funny TechEd video up.  This one’s funny even if you don't know them. :-)
Thursday, 17 March 2005 09:45:38 (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, 10 March 2005

…and good riddance. 

I was talking with Scott and some others at lunch today about the announcement that support is ending for VB6, and the ensuing petition.

OK, I understand that switching to VB.NET (or C#) will be fraught with pain, uncertainty and chaos. 

Get over it.  Cowboy up, people.  COM is dead (long live COM).

The bus is leaving… 

Thursday, 10 March 2005 16:05:06 (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  | 
I’ve had my Amateur Radio license for 8 months or so now, and haven’t spent too much time talking on it.  But…  Just recently I’ve discovered the groovy world of IRLP, or the Internet Radio Linking Protocol.  Me talking to a radio in Portland, which is connected via VoIP links to one or more other radios around the world that other people are talking to.  Pretty cool.  You can talk to people all over the world with just a handheld radio and a Technician license.  I made my first “long” distance contact last night, chatting with W2SBI in Virginia.  It’s a pretty strange juxtaposition of old and new technology, but hey, it works.  You can listen in to one of the IRLP reflectors from the web site.
Thursday, 10 March 2005 15:58:42 (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 

I’ve spent the last couple of days trying to get some ham radio related (yes, I’m that big a nerd) software to run on an old laptop I have at home.  I figured, being such an old and limited little machine, I’ll run Linux, since it will be small, light and agile on such hardware.  As ever, the Linux install itself went very smoothly (Debian 3.0).  I spent three solid days installing Linux back in like ‘93, so I appreciate how far installing has come.  It’s what happens after that.  I know I write code for a living, but I’ve discovered that when I get home, it’s not really what I want to do.  And the unfortunate truth of Linux (for me at least) is that everything that doesn’t come with your distro is next to impossible to run.  I just don’t have the patience to compile every piece of software that I want to use, especially since whatever libraries it depends on are NEVER the ones that I have. 

Sigh.  I know deep in my heart that Linux is cool.  I just don’t have that kind of time. 

As sad as it is, I gave up and installed the copy of 98 SE that came with the box.  And it just works.  Not nearly as flashy (Gnome is way cooler, hands down) but a solid performer.  Of course it took two days and several sets of drivers to get my D-Link WiFi card to work, but that’s a different story. :-)

Thursday, 10 March 2005 14:05:44 (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [2]  | 
# Wednesday, 23 February 2005
 Michele Leroux Bustamante posted a really great summary of how to go about creating a web service front end coupled to a multi-tier backend.  Check out the diagram at the end.  It makes it very clear.  I particularly like the use of the facade assembly on the web layer to talk to the business tier.  Very nicely done.
Wednesday, 23 February 2005 10:56:45 (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, 22 February 2005

I know things have been a bit quiet here lately.  Suffice it to say it’s been a weird winter so far.  I’m hoping to get some more technical content soon, but in the mean time…

I just got back from vacation in Phoenix, where it rained almost the entire time we were there, while here at home in (usually not so) sunny Portland it’s been sunny and in the 50’s and 60’s.  Good thing that whole global climate change is just a myth propagated by eco-freaks.  :-)

Tuesday, 22 February 2005 09:52:05 (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [3]  | 
# Tuesday, 08 February 2005
Bruce Sterling wrote a great review of the Voltaic Solar Backpack.  Pretty neat gizmo.  It’s a backpack with solar panels on the back that charge an internal battery, that in turn can be used to charge your cell phone/iPod/camera, etc.  I don’t know how well it would work here in the land where the sun is dim, but it’s a cool idea.  Energy self-sufficiency for one’s gizmos is a noble goal.
Tuesday, 08 February 2005 09:51:45 (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, 24 January 2005

I have a hobbyist level interest in linguistics, and one of the things I find most fascinating about language is the way it changes.  Modern English provides us with some pretty stunning examples.  I think they tend to fall into two categories.  There are abuses that are just plain wrong and should be severely dealt with, many of which can be found in our media (and political speeches).  These stem mainly from a lack of proper education, or just plain lack of attention.  I was a bit shocked to here Dr. Rice, in her confirmation hearings, talk about the “dismantlement” of our nuclear missiles.  This would be abuse. 

On the other hand, there are innovative uses of language that, IMHO, grow our language in interesting ways.  As I’ve mentioned before, I’m a huge fan of Buffy the Vampire Slayer, and one of the biggest reasons I love the show is for it’s innovative use of language.  There’s a cool page over at PBS right now about “Slayer Slang” and some of the innovative linguistic tidbits to come out of BtVS.  As but one small example, when told that something was “pointless”, Buffy responds “it’s totally pointy!”  That’s innovative use of language, and I think it should be applauded.

Given that, I was happy to see Wil Wheaton start a post today with the word “Embiggened”. :-)  Is it a word?  No.  Should it be?  Maybe.  Is it evocative and interesting?  Most definitely. 

Monday, 24 January 2005 10:23:20 (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 

 Henrik Gemal has added some code to Thunderbird (as a first step he says) to provide extra protection from phishing.   Sounds like a pretty good start to me.  You’ll get a warning if the link you clicked on in an email is an IP address instead of DNS, or if it’s a different address from the one in the text of the link.  A little goes a long way here, and this will certainly be a big help. 

Good work!

Monday, 24 January 2005 10:09:58 (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |