<?xml version="1.0"?><rss version="2.0">
<channel>
  <title>Alan&#039;s Ramblings - xml tag</title>
  <link>http://bleaklow.com:80/tags/xml/</link>
  <description>My opinions may be incorrect, but they are my own</description>
  <language>en</language>
  <copyright>Alan Burlison</copyright>
  <lastBuildDate>Wed, 29 Feb 2012 20:50:00 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  <image>
    <url>http://bleaklow.com/images/misc/logo.gif</url>
    <title>Alan&#039;s Ramblings</title>
    <link>http://bleaklow.com:80/</link>
  </image>
  <item>
    <title>XML-based J2EE frameworks considered harmful</title>
    <link>http://bleaklow.com:80/2007/05/03/xml_based_j2ee_frameworks_considered_harmful.html</link>
    <description>
          &lt;p&gt;
Are you using one of the XML-based web frameworks such as Spring, WebWork or 
Struts? Then you&#039;ve been duped. Conned. Flimflammed. Bamboozled. Hornswoggled. 
(Yes, this &lt;i&gt;is&lt;/i&gt; a rant ;-) Here&#039;s why:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;b&gt;XML doesn&#039;t get executed, it gets read&lt;/b&gt;&lt;br /&gt;
Unlike Java source code, XML just gets read once rather than being executed. That means that it 
can&#039;t respond dynamically to changes in the application environment. You are 
stuck with whatever is configured at the time the XML is read - usually this is 
at the very beginning of your applications startup processing.&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;XML doesn&#039;t have constants or variables&lt;/b&gt;&lt;br /&gt;Want to use the 
same configuration value across multiple XML files? Tough, you can&#039;t. The only 
way you can get even remotely near to this is to use &lt;a 
href=&#034;http://blogs.sun.com/alanbur/entry/why_i_hate_xml_configuration&#034; 
target=&#034;_blank&#034;&gt;vile preprocessing hacks&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;XML 
doesn&#039;t have flow-of-control&lt;/b&gt;&lt;br /&gt;Want to put some conditional logic or 
loops in your XML? Sorry, there&#039;s no standard way of doing this. Sure, some 
frameworks attempt to provide this using their own custom XML entities, but 
every one of them does it differently.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;XML files aren&#039;t 
programs&lt;/b&gt;&lt;br /&gt;All that good stuff you were taught in your CS classes about 
type safety, information hiding, coupling, cohesion and so forth? Forget it, 
thanks to XML you are now back in the 1960&#039;s.&lt;br /&gt; &lt;/li&gt;&lt;li&gt;&lt;b&gt;Welcome to 
action at a distance&lt;/b&gt;&lt;br /&gt;See that attribute you set in your XML? Well, 
that probably has to map onto a method call on an object. Which method and 
which object? Prepare to spend hours pouring over the source of your framework 
to find out.&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;You can&#039;t garbage-collect XML&lt;/b&gt;&lt;br 
/&gt;See all that XML goop you&#039;ve lovingly crafted? Well, say goodbye to large 
chunks of the memory on your machine. The application frameworks usually like 
instantiate all of the objects you might ever need at startup, because they 
have no way of knowing if they are ever used. And the frameworks make sure they 
are nailed into place, so forget about them ever being GC&#039;d if they aren&#039;t 
actually used.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;You&#039;d better understand all about 
classloader leaks&lt;/b&gt;&lt;br /&gt;All this XML you&#039;ve used requires all sorts of 
introspective sleight of hand by your application framework. And that involves 
getting it&#039;s grubby little hands into the Java runtime support mechanisms, and 
holding references to bits of its innards such as classloaders. And the next 
time you redeploy your application, all those references probably aren&#039;t going 
to be cleaned up properly, so say goodbye to lots of &lt;a target=&#034;_blank&#034; 
href=&#034;http://opensource.atlassian.com/confluence/spring/pages/viewpage.action?pa
geId=2669&#034;&gt;leaked memory&lt;/a&gt;. And if you redeploy just a few times more, expect 
your application to fall over completely as it runs out of memory.&lt;br /&gt;&lt;br 
/&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;You&#039;ve defeated type checking&lt;/b&gt;&lt;br /&gt;Most everything in XML 
ends up being a text string. That includes class names, method names and method 
parameters. Got one of them wrong? Oops, more mysterious exceptions will be 
heading your way at some random point in the future.&lt;br /&gt;&lt;br 
/&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Debuggers don&#039;t debug XML&lt;/b&gt;&lt;br /&gt;That cool debugger your IDE 
has? Don&#039;t bother. It doesn&#039;t work on XML files. The important bits of your 
application logic are now buried in some introspective labyrinth buried deep 
inside a library that you probably don&#039;t understand fully. Welcome instead to 
the world of cryptic stack traces and sleepless nights.&lt;br /&gt;&lt;br 
/&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;You can&#039;t run &lt;a target=&#034;_blank&#034; 
href=&#034;http://findbugs.sourceforge.net/&#034;&gt;FindBugs&lt;/a&gt; or &lt;a target=&#034;_blank&#034; 
href=&#034;http://pmd.sourceforge.net/&#034;&gt;PMD&lt;/a&gt; on XML&lt;/b&gt;&lt;br /&gt;Those nice tools 
that check your source code for programming errors? Guess what? They don&#039;t work 
on XML. You&#039;ve just thrown away another tool in your armoury.&lt;br /&gt;&lt;br 
/&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;You&#039;ve moved bug detection to run-time&lt;/b&gt;&lt;br /&gt;All that 
wonderful checking that the Java compiler does to make sure your application is 
correct? Gone, javac doesn&#039;t do XML. You aren&#039;t going to know if your 
application is even minimally correct until you try running it - and there&#039;s a 
fair chance that it will run for some considerable time before you find out 
that you&#039;ve made some simple programming error or other.&lt;br /&gt;&lt;br 
/&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;You still have to rebuild your application if you modify 
it&lt;/b&gt;&lt;br /&gt;XML proponents tell us that one of the major benefits of XML for 
configuring J2EE frameworks is that you can reconfigure your application 
without changing the source. Really? How? Does anyone ever change the XML files 
in a deployed WAR file? Of course not, that would be insane. Ah, you have to 
edit the source XML files then rebuild and redeploy your WAR file - Oh dear, 
you still would have had to do that even if you didn&#039;t use XML at all.&lt;br /&gt;&lt;br 
/&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;You&#039;ve just doubled your troubles&lt;/b&gt;&lt;br /&gt;Think that Java is a 
big, complicated language? You &#039;aint seen nothing yet. Faced with a big complex 
application and want to figure out who is calling a method? Well, don&#039;t expect 
your IDE to be of any help, it doesn&#039;t understand your application framework&#039;s 
XML files. Trying to trace through the code and figure out what happens? Forget 
it. You&#039;ll go insane hopping between Java and XML source and trying to figure 
out which bit of opaque magic provided by your application framework is doing 
what, where and when.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;I&#039;m fully aware that the list above is 
crammed with generalisations, and that there are various hacks and workarounds 
for some of the issues. However the overall point I&#039;m making is that XML isn&#039;t 
a programming language, yet virtually all of the major J2EE frameworks use it 
as if it is. The pervasive use of XML for tasks for which it is not suited has 
effectively discarded the last 30 years of software engineering advances. This 
is a huge mistake, and I expect that in 5 years time people will look back at 
the current XML mania and say &amp;quot;What the hell were we thinking 
of?&amp;quot;&lt;/p&gt;

</description>
      <category>Web</category>
    <category>Tech</category>
    <comments>http://bleaklow.com:80/2007/05/03/xml_based_j2ee_frameworks_considered_harmful.html#comments</comments>
    <guid isPermaLink="true">http://bleaklow.com:80/2007/05/03/xml_based_j2ee_frameworks_considered_harmful.html</guid>
    <pubDate>Thu, 03 May 2007 03:44:05 GMT</pubDate>
  </item>
  <item>
    <title>Why I hate XML configuration files</title>
    <link>http://bleaklow.com:80/2007/04/05/why_i_hate_xml_configuration_files.html</link>
    <description>
          &lt;p&gt;I&#039;m working on a reasonably large (1000+ source files) J2EE application that makes extensive (some might say utterly excessive) use of external components - it requires in the order of 50 JAR libraries to run, over and above the standard J2EE ones.&lt;/p&gt;&lt;p&gt;And of course many of those JAR files have their own unique XML files to configure them.&lt;/p&gt;&lt;p&gt;And of course many bits information related to the configuration of the application (URLs, database details etc) have to be repeated in more than one of those XML files.&lt;/p&gt;&lt;p&gt;And there&#039;s no global way of doing this.&lt;/p&gt;&lt;p&gt;So the people who originally wrote the application came up with a scheme - they&#039;d store the configuration values in property files.&lt;/p&gt;&lt;p&gt;But that only helped for things that got the values dynamically, for example by using the J2SE &lt;a href=&#034;http://java.sun.com/javase/6/docs/api/java/util/Properties.html&#034; target=&#034;_blank&#034;&gt;Properties&lt;/a&gt; class. All those external components they&#039;d used didn&#039;t know anything about the application&#039;s property files, they only knew about their own unique little XML files.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;So the people writing the application came up with another scheme - they&#039;d embed tokens in all those little XML files, then use the Ant &lt;a href=&#034;http://ant.apache.org/manual/CoreTasks/filter.html&#034; target=&#034;_blank&#034;&gt;Filter&lt;/a&gt; task to replace them at build-time with the values from the property files.&lt;/p&gt;&lt;p&gt;&amp;quot;&lt;a href=&#034;http://www.urbandictionary.com/define.php?term=jobs+a+good&#039;un&#034; target=&#034;_blank&#034;&gt;Job&#039;s a good &#039;un!&lt;/a&gt;&amp;quot; they doubtless exclaimed, flushed with their extreme cleverness.&lt;/p&gt;&lt;p&gt;Then I came along and had to maintain the beast, when I found:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;There are in excess of 50 of these properties, which makes configuring the application more than a little tedious and more than a little error-prone.&lt;/li&gt;&lt;li&gt;The names of the tokens
processed by the Ant Filter task and the names of the properties used to set their values mostly bear very little relationship to each
other.&lt;/li&gt;&lt;li&gt;There is no consistently-applied property naming scheme. There are in fact several inconsistently-applied naming schemes.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Some of the properties are just renamed versions of other properties. Sometimes they are inconsistently renamed versions of other properties. Sometimes they don&#039;t appear to be used at all.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;It isn&#039;t clear when reading a property file which properties are only used at compile time by the Ant Filter task, and which properties are only used at run time. It&#039;s also unclear which ones are used at both compile &lt;i&gt;and&lt;/i&gt; run time.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The compile-time use of properties is a killer because it means the application can&#039;t realistically be reconfigured without recompiling it - because the use of the Ant Filter task means the compile-time property file values end up hard-coded in many different places. It&#039;s therefore pretty much impossible to produce a version of the application that can be deployed on more than one machine - for example for development or test purposes.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;All this means that there&#039;s a whole series of bear traps set for anyone who innocently changes any of the properties files of the application, in the mistaken assumption that the application will actually take any notice of them.&lt;/p&gt;&lt;p&gt;I&#039;m sure I&#039;m not the only person to have been hit by this problem - how to configure multiple external components which all have their own XML configuration files - &lt;i&gt;without&lt;/i&gt; having to hand-edit each of the XML files each time every time something changes, and &lt;i&gt;without&lt;/i&gt; hard-coding the configuration at build time. However I&#039;m damned if I know of a good way of doing it - although I can easily think up several not-very-good ways of doing it.&lt;/p&gt;&lt;p&gt;If &lt;b&gt;you&lt;/b&gt; know, please let &lt;b&gt;me&lt;/b&gt; know!&lt;br /&gt;&lt;/p&gt;
</description>
      <category>Web</category>
    <category>Java</category>
    <category>Work</category>
    <comments>http://bleaklow.com:80/2007/04/05/why_i_hate_xml_configuration_files.html#comments</comments>
    <guid isPermaLink="true">http://bleaklow.com:80/2007/04/05/why_i_hate_xml_configuration_files.html</guid>
    <pubDate>Thu, 05 Apr 2007 14:38:44 GMT</pubDate>
  </item>
  <item>
    <title>Why I hate XML, and Ant&#039;s use of it in particular</title>
    <link>http://bleaklow.com:80/2006/03/25/why_i_hate_xml_and_ants_use_of_it_in_particular.html</link>
    <description>
          &lt;p&gt;
I was googling around for examples of how to sign a JAR file in Ant using the signjar task and came across &lt;a href=&#034;http://www.codecomments.com/message630181.html&#034;&gt;this&lt;/a&gt; monstrosity - 217 lines of turgid XML.  How anyone can say Ant is an improvement over make is a mystery to me, and how anyone could ever think that XML is fit for consumption by humans is an even &lt;b&gt;bigger&lt;/b&gt; mystery.  XML is food for machines, not people.  I sincerely hope that the current fad for doing &lt;a href=&#034;http://thedailywtf.com/forums/63360/ShowPost.aspx&#034;&gt;everything in XML&lt;/a&gt; (and we have some examples close to home) is going to an early grave.
&lt;/p&gt;&lt;p&gt;
What I&#039;m actually trying to do is to deploy an application via WebStart from within NetBeans - I&#039;ve loaded up the NetBeans WebStart module but it really doesn&#039;t cut the mustard yet, it doesn&#039;t support JAR signing, it hard-codes the name of the JNLP file and it assumes you want a WAR file building.  Here&#039;s hoping they make the necessary improvements in short order.
&lt;/p&gt;</description>
      <category>Tech</category>
    <category>Java</category>
    <comments>http://bleaklow.com:80/2006/03/25/why_i_hate_xml_and_ants_use_of_it_in_particular.html#comments</comments>
    <guid isPermaLink="true">http://bleaklow.com:80/2006/03/25/why_i_hate_xml_and_ants_use_of_it_in_particular.html</guid>
    <pubDate>Sat, 25 Mar 2006 08:26:49 GMT</pubDate>
  </item>
  </channel>
</rss>

