Tuesday, September 22, 2009

The excellent Mr. Haki blog

My morning routine has changed recently. I check out Mr. Haki, fire up the Groovy console and run the latest example.

I have been seriously impressed with the work Mr. Haki is doing.

Even if nobody reads this post, I want to at least help his search rankings!


Wednesday, September 16, 2009

jRecruiter presentation at AJUG

Gunnar Hillert gave an excellent presentation on his jRecruiter project at AJUG last night.

I will soon be downloading jRecruiter to check it out in more depth. Gunnar mentioned that the Maven build is a little wonky at the moment. He said he would fix it in the next week or two.

He has a lot of really cool stuff in the app:
  • Struts 2.1, which I have not used. I spent years using the Struts 1.* releases, but have been in the JSF camp for a while now.
  • Twitter integration, which I've wanting to check out.
  • GZip and minification.
Check out the project or his blog for a complete list.


Friday, September 11, 2009

"The processing instruction target matching "[xX][mM][lL]" is not allowed."

I often put the Xml I use for test cases inside of Groovy classes. This allows me to make use of multiline Strings.

String inputXml = '''
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<records>
<record>
<recordid>833432</recordid>
<name>Lorem ipsum dolor</name>
<parentid>0</parentid>
<link>http://consectetueradipiscingelit</link>
<date>9/10/2009</date>
<description>Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.</description>
<category ID="48015"></category>
<category>In enim justo</category>
</record>
</records>
'''


I ran into this error today :

"The processing instruction target matching "[xX][mM][lL]" is not allowed."

I'm surprised I hadn't run into it before. The problem was that I had white space before the xml prolog.

There are two easy solutions :
  1. Remove the whitespace.
  2. Call "trim()" on the String.

Whitespace removed :
String inputXml = '''<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<records>
<record>
<recordid>833432</recordid>
<name>Lorem ipsum dolor</name>
<parentid>0</parentid>
<link>http://consectetueradipiscingelit</link>
<date>9/10/2009</date>
<description>Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.</description>
<category ID="48015"></category>
<category>In enim justo</category>
</record>
</records>


trim() called :

String inputXml = '''
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<records>
<record>
<recordid>833432</recordid>
<name>Lorem ipsum dolor</name>
<parentid>0</parentid>
<link>http://consectetueradipiscingelit</link>
<date>9/10/2009</date>
<description>Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.</description>
<category ID="48015"></category>
<category>In enim justo</category>
</record>
</records>
'''.trim()