Castor and the Namespace bug

While working with a new version of Castor I recently encountered a strange error during unmarshalling (creating Java object out of corresponding XML schema). The error was as follows:

java.lang.IllegalArgumentException: The prefix ‘xml’ is reserved (XML 1.0 Specification) and cannot be declared.

Luckily, some Googling brought me to this thread which explains the probable reasons for this “bug”. As it suggested (and it works since I incorporated it) we need to set the namespaces property to true in the castor.properties file as follows (caveat: needs to be done with Xerces 2.5 only):

org.exolab.castor.parser.namespaces = true

Following is a quote from the said thread, which is in fact a reply from Keith Visco, the Castor XML project lead, that throws light on the cause of the bug:

The issue seems to be with newer versions of Xerces. The older version that ships with Castor works fine. For some reason, when the newer version of Xerces encounters an “xml” prefixed attribute, such as “xml:lang” it tries to automatically start a prefix mapping for “xml”. Which, in my opinion, is technically incorrect. They shouldn’t be doing that. According to the w3c, the “xml” prefix should never be declared.

The reason it started appearing in the new Castor (0.9.5.2), was because of a switch to SAX 2 by default during unmarshalling. I found a simple workaround (tested with Xerces 2.5) , at first I thought about disabling namespace processing in Xerces, but then realized that it’s already disabled by default by Castor…so I have no idea why they call #startPrefixMapping when namespace processing has been disabled. But in any event…explicitly enabling namespace processing seems to fix the problem.

Holly-Bolly ke bahane

Watching the closing credit title of a Hollywood movie makes me appreciate their dedication to the art. All people who put in their effort seem to get the due credit; so one is not surprised to see the credit for the “Teenager at the disco” or “The fifth waiter” or the “lady at street corner”. Many of the credit titles are very funny and many very artistic. On the contrast the Bollywood1 flicks seem to concentrate on the opening credit and by the time the movie reaches finale, by which time half of the janata2 already gallops for the exit gates, the director himself seem to loose his interest in his movie (so typical of David Dhawan). What you get at the end of the movie is just a replay of a happy-go-lucky song from the movie with the credits running insipidly along side acknowleding the efforts put in by the film financer, friendly-neighbourhood banker and the superstar who did that 2-second obliging sequence. You can't even expect the decency from the producers to express their gratitude for the numerous technicians who put in their effort including those stuntmen who are at far greater risk doing stunts here compared to their Hollywood counterparts, who apart from the insurance factor get the advantage of all the safety-precautions technology can provide while performing a stunt.

To me this is a display of the typical Indian mindset, first: we embark on a work but we do not finish it with the same vigour, we even go the extent of losing interest by the end. Second: we don't give a damn about people who helped us in our work, all our glory is due to us, we tend to forget those on whose shoulders we stand. Thirdly: only our life is important and other's a thing to waste. Isn't this ethos visible in all walks of Indian life? We tell our illetrate chowkidaar3 to change our broken fuse fearing we would get an electrical shock if we did it on our own, we tell our 8 year old girl-servent to babysit and carry our baby all day long, we savor all the delicacies on the festivities with our well-fed neighbours forgetting the safai-wala who cleaned your house to sparkles for the occassion. This may sound melodramatic but we just need to peep inside our own proverbial girehbaan.

1 The common term for the Indian Hindi film industry 2 Hindi for public 3 Hindi for watchman 4 Urdu for collar

Happy Deepawali!

Wishing a very happy Diwali and prosperous new year to all my readers, friends and relatives. Hope you have a blast this festival of lights!