How I made html look almost like word

So one of my projects was to take an existing program and port it to the SAP Web Portal. Yippee… not… The existing program was written in VB and takes data from some source, don’t know what it was, and plugs it into a set of word templates, and the templates are merged together to make a single Word document. At the time time I did not know anything about Apache POI and looking back at that technology, it really wasn’t that well developed.

So what was the solution that I proposed? Since it is going to be on the SAP Web Portal why not display it in HTML format? I mean it is a web page. All the nodding heads nodded, and all the nay sayers started to plot my destruction. So the data coming from R/3 was a given. So how would I display the data? I had to mimic the merging of documents as before. Average Joe Body Builder’s solution was to have the data returned in a flat XML string, and then XSL would have been used to transform the data to HTML. Java was used to execute the transformation. What about the merging? The XSL’s had to be merged. Since XSL is just a grammar of XML I used another set of XSL to merge the XSL’s together. Lovely. For those of you who would like sample code please place some comments, and I will do so.

Data was retrieved from R/3 using JCA/O, since that data was in XML format the rest of the process was as is described above. I had some utility functions to determine if the connection to R/3 was successful, that was important since the stability of the entire SAP Web Portal was like ummm not there! So I had to actually assume that connection to R/3 would at first fail before it would succeed.

I must say I did learn alot about how management works in this place. Basically it is “you will do what we tell you before we even tell you it!” and if we need something from management it is “we will get back with you at our earliest convenience”. This is during the time that I started to become more health conscious after a period of about 13 years. I would like to thank, we will call him M (M for Moe), for that. More on that later.

So in any case, R/3 to XML transformed to HTML. The HTML used a combination of CSS and javascript to make the result look almost like the origina word document! What do you say?!