Monday, May 18, 2009

Screw experts-exchange

If you post on experts-exchange you're a dick, plain and simple. Even the crappiest of programmers can attest to the fact that they've used the internets a million and one times to help them code. Anytime you're trying to do anything you search and read blogs and forums and and all that. If there is any example of how free information benefits real business it'd be computer programming.

So why does experts-exchange show up all the time on my searches? Well, I have a theory and it involves a fat nerd living in his moms basement, too much mountain dew and manga and not enough social interaction with those of the opposite sex. God that site pisses me off.

Friday, May 8, 2009

JAXB xjb & too many nodes

As I went into a while ago, you can use xjb to customize JAXB bindings. Today I learned of a tragic shortcoming. So say you have this snippet
<jaxb:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
 version="1.0">
 <jaxb:bindings schemaLocation="train.xsd" node="//xsd:element[@name='car']">
  <jaxb:property name="cars" />
 </jaxb:bindings>
</jaxb:bindings>
In that example there was a complexType with the name train, which contained an element with the name car which corresponded to the complexType car. All is right in the world. But what if there was another element somewhere, probably in some other complexType that contained a car? Well, that'd be kosher unless you were trying to customize the bindings with the above snippet. Instead you'll end up seeing
[ERROR] Error while parsing schema(s).Location [ file:/C:/Dev/Workspace_Netbeans /my-project/src/main/resources/train.xjb{5,80}].com.sun.istack.SAXParseException2: XPath evaluation of "//xsd:element[@name='widget']" results in too many (2) target nodes
There was an enhancement request put in years ago for XPath to be able to match multiple nodes, but like Bill O'Reilly releasing a softcore romance novel I wouldn't hold my breathe. Oh wait.