Friday, November 13, 2009

MSBuild + XMLUpdate + XPath + Namespaces

Today I came across an issue trying to use an XMLUpdate statement against the web.config in our team deployment build, and while the Googling did end up helping me resolve the issue, it didn't turn up any direct results that really showed/explained what I needed to do. So what would Brian Boitano do? Well, besides using his magical fire breath to save a maiden, he'd probably decide to dig up the rotting corpse of his blog and fill the void himself. So here we are!

Anyways, check out the relevant chunk of my config file (sensitive info obfuscated, of course):

xml version="1.0"?>



<openaccess xmlns="">


<reference assemblyname="OurAssembly.Name" configrequired="True" />



<connection id="OurDatabase">









<backendconfiguration id="mssqlConfiguration" backend="mssql">











As you can see, we're using the Telerik OpenAccess ORM tools. My goal was to insert some values into the connectionParams node specific to our deployed application scenario, so I originally had a statement in the team build proj file that looked like this:

<XmlUpdate XmlFileName="%(WebConfig.FullPath)"


Value="AttachDbFileName=$(DropLocation)\$(LabelName)\$(Configuration)\_PublishedWebsites\$(WebProjectName)\OurDB.mdf" />

Unfortunately, it didn’t work. After some digging I discovered that the xmlns attribute on the openaccess node messes with XPath, and that I could use a Namespace attribute to help solve that problem, but nothing really showed how exactly to do it. I used a little trial and error and came up with the solution as seen here:

<XmlUpdate XmlFileName="%(WebConfig.FullPath)"




Value="AttachDbFileName=$(DropLocation)\$(LabelName)\$(Configuration)\_PublishedWebsites\$(WebProjectName)\OurDB.mdf" />

So as a way of explanation, we define the namespace we're hunting for and assign it a prefix. Then, in the XPath, we use the prefix for any node that falls within that namespace, but not for the nodes before it takes effect (such as configuration).

All of this info is out there on the web in pieces, and I'm sure smarter folks than I can put it together quickly and move on, but hopefully this post will help the other goobers like me who would otherwise take an hour or two to put all the pieces of the puzzle together.

Faithfully yours,

Code Baboon

Friday, May 29, 2009

Inspiration Ain't No Dime-Store Booty Call

If there is something I've learned over the 30-some years I've sullied this planet with my presence, it's that creative inspiration is not your average mistress.

You see, your average mistress is just a 7 digit SMS away, always lustily awaiting your poetic summons. "Motel 6 rte 53 7pm smel good". As you pull up to that grungy roadside inn, 10 minutes late and whiffing of stale rye, you can be certain that your average mistress is patiently waiting inside, ready to get the business. 25 minutes and one step closer to hell later, your average mistress will blissfully watch you leave, reassuring you all the while that she really doesn't mind taking the city bus to meet up. It's only one transfer, and besides, it gives her uninterrupted time to think just of you.

But inspiration... inspiration is a much different creature. Inspiration flits around the edges of your mind all day, but never heeds your call. Inspiration does not arrive at a time of your choosing, but rather taps incessantly on your bedroom window at 2:45am while you lay beside your gently sleeping betrothed. At times inspiration will disappear for weeks, even months, nowhere to be found. There is no note, no phone call, no "Gone to Cancun, back next week with pics" text message. Simply an empty void where something important should be. No, inspiration ain't no dime-store booty call.

So, what to do when inspiration comes knocking, awkwardly thrusting it's heaving bosom of creativity in your direction at the most unworkable of times? Do you risk turning it away, spurning the unique joy and passion that only inspiration can provide, perhaps not to see it again for what may seem an unlivable period of time? Or do you drop what you're doing, hand your 5 year-old child a $20 bill and say "I've got another one of these for you if I don't see you for the next hour", and harken the call of your supple muse?

Ultimately, it's your call. But perhaps the most vexing attribute of inspiration is that even when you welcome it and embrace it, even as you relish awash in the waves of sheer beauty emanating from it, and often just as you are certain you are experiencing the most climactic of surreal epiphanies, even with all that, time and again it will simply vanish, and your handiwork is left unfini-

Tuesday, May 19, 2009

Too. Much. Fun

I've been blessed with a new laptop here at work, and so over the last week I've slowly been transitioning to it. Today I went to open a PDF document and realised that I had yet to install a PDF Viewer. Now, I've long hated Acrobat Reader due to it's terrible load times, and a few years back discovered a much better option in Foxit Reader. However, I felt it might be time to take a quick look at the PDF Viewer landscape and see if anything else might have popped up that I could try out.

As luck (or Google) would have it, I came across some positive feedback regarding something called PDF-XChange Viewer. Normally a name that lame is enough to turn me away, but the good feedback I read convinced me to at least check it out. So I went to the download section and saw that they had both a regular version and a 'portable' version. Curiously, the portable version was for normal Windows systems, not mobile systems as I had initially expected, so I was interested to see what the feature differences existed between the two. Luckily, there is a link to a feature comparison, as seen here:
This is where the awesome kicks in. Clicking that link yields the following gem:

Yes, that's right: in order to adequately judge which PDF Viewer to download the user must first have a PDF Viewer installed. Genius! Too bad there isn't a handy document format that this information could have been stored in which would have allowed people to view the information without requir--- WHY THE DEUCE IS THIS CHART NOT HTML?!