Pradeep's Blog


Tuesday, December 12, 2006

Data Mapping Using Xsl

In B2B communications resolution of data between trading partners is one of the most important issue. Let’s consider a scenario where your trading partner sends you a Purchase Order and this PO has got only got a shipping address id. Once you get this PO, you must resolve the shipping address id to an actual destination so that your delivery guys can deliver it. Except the few Big ERP systems most ERP systems do not have to capability to resolve this id to a particular address. Hence the data has to be resolved by a pre-process before the PO enters your ERP System.

Thought there are lots of ways to map information between partners, let me show you how it can be done using an XML mapping file. Let’s also considered that the incoming file is either’s XML or has been transformed to XML. I’ll now show you how an address id can be mapped to the complete address.

Lets consider that the Xml file that we get have the address id as shown

Now instead of the ident field inside the partyaddress something like this would be very useful

In order for us to map the ID to the address we need a mapping file. The actual mapping file could be something like the one shown below; this mapping file will be used in the xsl file to populate the address instead of the address ids.
Now the Xsl part, this is where the actual mapping is done. In the Xsl file create a variable that reads the mapping file like

Now to get the city mapped we could map it as shown above. Here the @id in the mapping file is compared with the ident field in the main xml file. If they are equal then we get the city name from the mapping file.

Tuesday, October 31, 2006

Google Bomb

Before me telling what Google Bomb is try searching for miserable failure or failure and liar in Google. Got the answer? Those two are perfect examples of Google bombing. As you all know Google Search has a set of rules by which it ranks pages. So once you understand how these rules work, you can build pages that get better ranking for a particular keyword. The most important criterion for page ranking by Google is the number of pages that link to your page with that keyword. Now that you know this, you can increase the page rank of your webpage for a certain keyword, by increasing the number of links to your page with that keyword. The more the number of pages that link to you with the specific keyword the better the ranking.
The process of influencing Google’s ranking by flooding the pages on the net, with links to a particular page (with a certain keyword) is known as Google Bomb. Most of these Bombs are dropped for commercial reasons.

Sunday, September 17, 2006

Deploying AJAX application created using Google’s Web Toolkit

AJAX without java script! Few months back and I wouldn’t have believed this would be possible. With Google’s Web Toolkit you could code your AJAX applications in Java, and it converts it into Java script for you. Any application created using this Toolkit has three parts to it. First the client side code, this is the code that gets converted into Java script (and runs on the browser) , then the server side code this is the part of the application that runs in your web server (like Tomcat), then the public files, these can be any images or other files that are required by your application.

Since the client side code is translated into Java script, your client side code can only have features that a normal web browser can support (So features like Threads are not supported). In the server side code you can do any thing that Java supports.

The Google’s web toolkit supports two modes for running your AJAX applications. The first one is the hosted mode; this mode is very useful while developing the application. In this mode Google’s simulates the output of your application. The other mode is the web mode. In this mode the Java code is compiled into Java script code and you can run your application from a web server.

The documentation provided by Google for deploying the application in web mode is very limited. I recently deployed my application in Tomcat 5.5 and these are the steps that I followed,

1. Use the application.compile.cmd file to create all the client side files. These files would be placed in the www directory.
2. Get all the server side files compiled.

Consider that we are going to deploy in the ROOT directory in a tomcat.

1. Copy all the client side files (the content of the www directory) into the ROOT directory in tomcat.
2. Then copy all the classes (server side) files to ROOT/WEB-INF/Classes directory.
3. If there are any dependent jar files copy them to ROOT/WEB-INF/lib directory. [NOTE: The packages javax.servelt.*; have to be removed from both the jar files that are provided by Google].
4. Then map the server side servlets (the classes that talk to the client) via the web.xml file in the ROOT/WEB-INF directory.

The url pattern in the servlet mapping should be same in the client code, the application.gwt.xml and in the web.xml files.
If even after following these steps you have problems running you application in web mode, see your web server's logs for more information.

Friday, August 18, 2006


Over the past few months there has been a buzz about the term AJAX. AJAX stands for Asynchronous Javascript And XML.

AJAX as a technology came into the spotlight mainly after Google (GMail) started using it. But AJAX is not a completely new technology, it's old technology with some new tricks to improve the interactiveness of the webpages.

One good news for coders is that you probably know most of the technologies behind building AJAX applications. Some of the technologies involved are HTML, Javascript, DOM, and XML. AJAX appliactions are much more responsive because they are able to send requests to the server without actually reloading the whole page. This is achieved by using the XMLHttpRequest object. The XMLHttpRequest Object enables us to bypass the normal request mechanism followed by the web pages (where the whole page actually reloads) . Instead this object along with Javascript makes it possible to send information to the server without actually refreshing the page, and thus improving interactiveness.

Even Microsoft has taken note of the huge popularity of AJAX and (as always) has planned to have "it's own" AJAX, which is to be integrated with ASP.Net soon.

Monday, July 17, 2006

Search Engine Optimization Tools

As a search engine optimiser (SEO) you definitely require a set of tools that display your ranking in various search engines, generate keyword, analyse backlinks, etc. Listed below are the various free tools that are available on the net for SEO.

Ranking in various search engines:

In order to use this tool you need to register with Google and get an API key. This tool enables users to check the rank of your web site for a certain key word with Google, Yahoo and Msn.

I was able to get a high ranking of 16 for my site for the key words “software complexity”.
Keyword Suggestions/Density Checker:
Though most search engines do not consider the keywords anymore for better ranking, its better to have appropriate keywords in your sites. These tools can help you in deciding keywords.

Though these tool are good it would have been better if it could narrow down the keywords rather that giving a big list for us to choose from.
Other tools:
These are other third party tools that are available for free on these sites

Though these sites provide free tools using Google’s API, I consider most of the functionality provided by these tools to be redundant.
Google’s Alert:

One other good tool that might help webmaster to get more backlinks to their sites is to register with Google alert. With this alerting facility you can easily build more backlinks. Click here to register

Monday, July 03, 2006

Passing parameters to XSL from Java

Generating a HTML from XML can be done using the javax.xml.transform class in the Java’s API. The transformation can be done using the code below;

TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer
( new FileOutputStream(htmlFileName)));

Note: Remember to provide the correct XSL, XML and HTML file names and the XSL and the XML file should be valid (i.e. all tags should be closed properly)

Now, suppose you want to customise the HTML output depending on certain criteria in your program, how do you do that? This can be done by sending information to the XSL file as parameters. So, the next big question, how can parameters be passed into the XSL file from a java programme?
The javax.xml.transform class provides you with a method called setParameter(String name, Object value). An example of this is given below;

Timestamp ts = new Timestamp(System.currentTimeMillis());
transformer.setParameter("timestamp", ts);

Here the timestamp is passed to the XSL filename. The XSL file can get this value by using a global param field as shown below.
<xsl:param name="timestamp"/>

and used like this
<xsl:value-of select="$timestamp"/>

to print the time that is obtained from the java class.

Note: The parameter name in the XSL should match the one in the java class.

Sunday, July 02, 2006

CyVis v0.9.0 Released!

Are you a Java developer? Do you want a tool that visualises the complexity of your software? We have just released the first public version of CyVis.
CyVis is a software metrics collection, analysis and visualisation tool for software built using Java. It enables developers to identify complex part of their software very easily.
CyVis collects data from java class or jar files hence there is no need for the actual source code. Once the metrics are collected, the statistical information is shown in a way that enables you to immediately detect which part of your software is complicated and which is not.
CyVis can either be integrated with your Ant script or used in command interface to generate reports. It also has a GUI Interface which we consider to be of great help to its users.
Try this cute little tool once and you will love it. Visit for more information.