<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>lstierneyltd &#187; quick tips</title>
	<atom:link href="http://lstierneyltd.com/blog/category/development/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://lstierneyltd.com/blog</link>
	<description>Yet another development blog</description>
	<lastBuildDate>Wed, 13 Jul 2011 12:55:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>The Processing Instruction Target Matching &#8220;[xX][mM][lL]&#8221; is Not Allowed</title>
		<link>http://lstierneyltd.com/blog/development/tips/the-processing-instruction-target-matching-xxmmll-is-not-allowed/</link>
		<comments>http://lstierneyltd.com/blog/development/tips/the-processing-instruction-target-matching-xxmmll-is-not-allowed/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 08:54:18 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[quick tips]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=268</guid>
		<description><![CDATA[Background When parsing XML you receive the following error: ...The Processing Instruction Target Matching "[xX][mM][lL]" is Not Allowed... Solution The chances are you have some sort of whitespace (or control character) infront of your XML declaration: ..&#60;?xml version="1.0" encoding="utf-8"?&#62; It may even be that you have more than one XML declaration in the document..!]]></description>
			<content:encoded><![CDATA[<h4>Background</h4>
<p>When parsing XML you receive the following error:</p>
<pre>
...The Processing Instruction Target Matching "[xX][mM][lL]" is Not Allowed...
</pre>
<h4>Solution</h4>
<p>The chances are you have some sort of whitespace (or control character) infront of your XML declaration:</p>
<pre>
..&lt;?xml version="1.0" encoding="utf-8"?&gt;
</pre>
<p>It may even be that you have more than one XML declaration in the document..!</p>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/tips/the-processing-instruction-target-matching-xxmmll-is-not-allowed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Read a File as String with Java</title>
		<link>http://lstierneyltd.com/blog/development/tips/read-a-file-as-string-with-java/</link>
		<comments>http://lstierneyltd.com/blog/development/tips/read-a-file-as-string-with-java/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 08:19:36 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[How to's]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=264</guid>
		<description><![CDATA[Introduction I&#8217;m always Googling for a way to do this. This seems to be the best &#8220;idiomatic&#8221; solution I&#8217;ve found. So without further ado&#8230; Example]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>I&#8217;m always Googling for a way to do this. This seems to be the best &#8220;idiomatic&#8221; solution I&#8217;ve found. So without further ado&#8230;</p>
<h3>Example</h3>
<pre class="brush: java; title: ; notranslate">
public String readFile(String path) throws IOException {
    FileInputStream stream = new FileInputStream(new File(path));
    try{
        FileChannel fc = stream.getChannel();
        MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
        return Charset.defaultCharset().decode(bb).toString();
    }
    finally {
        stream.close();
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/tips/read-a-file-as-string-with-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>View Source of Oracle Trigger</title>
		<link>http://lstierneyltd.com/blog/development/tips/view-source-of-oracle-trigger/</link>
		<comments>http://lstierneyltd.com/blog/development/tips/view-source-of-oracle-trigger/#comments</comments>
		<pubDate>Wed, 11 May 2011 12:09:09 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[quick tips]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=257</guid>
		<description><![CDATA[select trigger_body from user_triggers where trigger_name = 'XXXXX']]></description>
			<content:encoded><![CDATA[<pre>
select trigger_body from user_triggers where trigger_name = 'XXXXX'
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/tips/view-source-of-oracle-trigger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DB2&#8242;s equivalent of Oracle&#8217;s &#8220;dual&#8221;</title>
		<link>http://lstierneyltd.com/blog/development/tips/db2s-equivalent-of-oracles-dual/</link>
		<comments>http://lstierneyltd.com/blog/development/tips/db2s-equivalent-of-oracles-dual/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 18:27:46 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[DB2]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=214</guid>
		<description><![CDATA[This is really a quick example of DB2&#8242;s equivalent of Oracle&#8217;s &#8220;dual&#8221; Get current date/time in DB2 select current date from sysibm.sysdummy1]]></description>
			<content:encoded><![CDATA[<p>This is really a quick example of DB2&#8242;s equivalent of Oracle&#8217;s &#8220;dual&#8221;</p>
<p>Get current date/time in DB2</p>
<pre>
select current date from sysibm.sysdummy1
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/tips/db2s-equivalent-of-oracles-dual/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Access a Spring Bean from within a Servlet</title>
		<link>http://lstierneyltd.com/blog/development/tips/access-a-spring-bean-from-within-a-servlet/</link>
		<comments>http://lstierneyltd.com/blog/development/tips/access-a-spring-bean-from-within-a-servlet/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 11:03:38 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=196</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: java; title: ; notranslate">
ApplicationContext context =
    WebApplicationContextUtils.getWebApplicationContext(getServletContext());
MyService service = (MyService) context.getBean(&quot;serviceBeanName&quot;);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/tips/access-a-spring-bean-from-within-a-servlet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selenium Tests Randomly Failing</title>
		<link>http://lstierneyltd.com/blog/development/tips/selenium-tests-randomly-failing/</link>
		<comments>http://lstierneyltd.com/blog/development/tips/selenium-tests-randomly-failing/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 09:10:43 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[quick tips]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=178</guid>
		<description><![CDATA[The Problem The project I&#8217;m currently working on uses a lot of selenium tests to verify the behaviour of the web front end and, I must say, I&#8217;ve been quite impressed with it. Yesterday however after updating my local machine with the latest copy of the project from Clearcase I noticed a lot of failing [...]]]></description>
			<content:encoded><![CDATA[<h4>The Problem</h4>
<p>The project I&#8217;m currently working on uses a lot of <a href="http://seleniumhq.org/" target="_blank">selenium tests</a> to verify the behaviour of the web front end and, I must say, I&#8217;ve been quite impressed with it.</p>
<p>Yesterday however after updating my local machine with the latest copy of the project from Clearcase I noticed a lot of failing tests; the worrying (interesting?) thing though was that the failures appeared to be &#8220;random&#8221;. Tests were passing one run and failing the next, with no changes having being made in the source code and no changes in the initial starting conditions. I was starting to pull my hair out. Curiously the tests ran fine on my colleagues&#8217; and the build machine. My workmate had a look (remember the tests ran fine for him) but he too was getting the random failures on my machine &#8211; we were both stumped.<br />
<code><span id="more-178"></span></code></p>
<p>He did unknowingly hit on the problem when he said &#8220;Your machine is a lot zippier than mine&#8221;. After another hour or so the problem and solution became obvious.</p>
<h4>Cause</h4>
<p>The Selenium remote control was executing the steps of the test faster than my local app server and Firefox could keep up. In other words it was trying to verify elements on the page before they had rendered.</p>
<h4>Solution</h4>
<p>To quickly check my hypothesis I ran the Selenium Tests in &#8220;slow mode&#8221; &#8211; all the tests passed!</p>
<p>Now, going forward, I will need to check the test source for all snippets like</p>
<pre class="brush: plain; title: ; notranslate">
browser.click(&quot;someButton&quot;); // causes page to load
verifyTrue(browser.isTextPresent(&quot;someText&quot;));
</pre>
<p>and change them to</p>
<pre class="brush: plain; title: ; notranslate">
browser.click(&quot;someButton&quot;);
browser.waitForPageToLoad(&quot;30000&quot;);
verifyTrue(browser.isTextPresent(&quot;someText&quot;));
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/tips/selenium-tests-randomly-failing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dos to Unix (Dos2Unix) with Eclipse</title>
		<link>http://lstierneyltd.com/blog/development/tips/dos-to-unix-dos2unix-with-eclipse/</link>
		<comments>http://lstierneyltd.com/blog/development/tips/dos-to-unix-dos2unix-with-eclipse/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 08:49:20 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[quick tips]]></category>
		<category><![CDATA[dos2unix]]></category>
		<category><![CDATA[eclipse]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=175</guid>
		<description><![CDATA[1. Open the file in Eclipse that you wish to &#8220;Dos2Unix&#8221; 2. File -> Convert Line Delimiters To -> Unix Profit!]]></description>
			<content:encoded><![CDATA[<p>1. Open the file in Eclipse that you wish to &#8220;Dos2Unix&#8221;<br />
2. File -> Convert Line Delimiters To -> Unix</p>
<p>Profit!</p>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/tips/dos-to-unix-dos2unix-with-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JAXB @XmlAnyElement example</title>
		<link>http://lstierneyltd.com/blog/development/tips/jaxb-xmlanyelement-example/</link>
		<comments>http://lstierneyltd.com/blog/development/tips/jaxb-xmlanyelement-example/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 15:06:52 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[annotations]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jaxb]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=134</guid>
		<description><![CDATA[The problem I was recently working on a JAXB centric app which was required to capture &#8220;arbitary&#8221; xml. e.g. How could I ever capture the contents of if they could be &#8220;anything&#8221;? The solution What&#8217;s going on? The @XmlAnyElement annotation instructs JAXB to hoover up any elements which aren&#8217;t already annotated/associated with a field and [...]]]></description>
			<content:encoded><![CDATA[<h4>The problem</h4>
<p>I was recently working on a JAXB centric app which was required to capture &#8220;arbitary&#8221; xml. e.g.</p>
<pre class="brush: plain; title: ; notranslate">
&lt;a&gt;
   &lt;b&gt;&lt;/b&gt;
   &lt;c&gt;&lt;/c&gt;
   &lt;d&gt;
       &lt;!-- &quot;Unknown&quot; XML here --&gt;
       &lt;maybeE&gt;&lt;/maybeE&gt;
       &lt;maybeF&gt;&lt;/maybeF&gt;
       &lt;!-- etc etc --&gt;
   &lt;d/&gt;
&lt;/a&gt;
</pre>
<p>How could I ever capture the contents of <d> if they could be &#8220;anything&#8221;?<br />
<code><span id="more-134"></span></code></p>
<h4>The solution</h4>
<pre class="brush: plain; title: ; notranslate">
@XmlRootElement(name=&quot;a&quot;)
public class A { 

   @XmlElement
   private String b; 

   @XmlElement
   private String c; 

   @XmlAnyElement
   private List&lt;Element&gt; content;
}
</pre>
<h4>What&#8217;s going on?</h4>
<p>The <strong>@XmlAnyElement </strong> annotation instructs JAXB to hoover up any elements which aren&#8217;t already annotated/associated with a field and store their DOM representation in:</p>
<pre>
private List<Element> content;
</pre>
<p>You could then do something like:</p>
<pre class="brush: plain; title: ; notranslate">
public String getContentAsString() throws Exception{
    StringBuilder builder = new StringBuilder();
    for (Node node: operations) {
        StringWriter writer = new StringWriter();
        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, &quot;yes&quot;);
        transformer.transform(new DOMSource(node), new StreamResult(writer));
        builder.append(writer.toString());
    }
    return builder.toString();
}
</pre>
<p>To get the nested XML as String.</p>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/tips/jaxb-xmlanyelement-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to convert a CLOB to an XMLType in Oracle</title>
		<link>http://lstierneyltd.com/blog/development/tips/how-to-convert-a-clob-to-an-xmltype-in-oracle/</link>
		<comments>http://lstierneyltd.com/blog/development/tips/how-to-convert-a-clob-to-an-xmltype-in-oracle/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 13:17:23 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[plsql]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=125</guid>
		<description><![CDATA[Not much comment to add here; code says it all PROCEDURE clobToXMLType(myClob IN CLOB) IS l_xmlType XMLTYPE; -- do something BEGIN l_xmltype := XMLTYPE.createXML(myClob); EXCEPTION WHEN OTHERS THEN RAISE; END clobToXMLType;]]></description>
			<content:encoded><![CDATA[<p>Not much comment to add here; code says it all</p>
<pre>
PROCEDURE clobToXMLType(myClob IN CLOB)

IS
    l_xmlType XMLTYPE;
    -- do something
BEGIN
    l_xmltype := XMLTYPE.createXML(myClob);

EXCEPTION

    WHEN OTHERS THEN
    	RAISE;

END clobToXMLType;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/tips/how-to-convert-a-clob-to-an-xmltype-in-oracle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reset Gnome desktop the easy way</title>
		<link>http://lstierneyltd.com/blog/development/tips/reset-gnome-desktop-the-easy-way/</link>
		<comments>http://lstierneyltd.com/blog/development/tips/reset-gnome-desktop-the-easy-way/#comments</comments>
		<pubDate>Sun, 16 May 2010 10:17:04 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[quick tips]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=109</guid>
		<description><![CDATA[I recently upgraded Ubuntu on one of machines from 9.10 (Karmic Koala) to 10.04 (Lucid Lynx). In the old version I had installed a lot of widgets, messed up the fonts, buttons &#8211; loads of things. I needed an easy way to restore/reset the Gnome desktop back to the default look and feel. I could [...]]]></description>
			<content:encoded><![CDATA[<p>I recently upgraded Ubuntu on one of machines from 9.10 (Karmic Koala) to 10.04 (Lucid Lynx). In the old version I had installed a lot of widgets, messed up the fonts, buttons &#8211; loads of things. I needed an easy way to restore/reset the Gnome desktop back to the default look and feel.</p>
<p>I could of course have used the gui&#8217;s to undo all the changes I made but why bother? This is Linux after all!</p>
<pre>
# cd
# [sudo] rm -rf .gnome .gnome2 .gconf .gconfd .metacity
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/tips/reset-gnome-desktop-the-easy-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

