Perl and XML

ajt on 2002-07-02T20:58:27

I like XML! I learnt HTML before I learnt Perl, and I perviously worked for Inso, who were heavily into SGML/DOM/XML. Combining Perl and XML has until recently been a very slow and painful process, and as anyone can see from a book shop XML goes with Java not Perl....

Recently I got involved in a project to web enable our repair reporting process for customer services and the repairs department. The back-end system is a very complex and overblown SAP system, which is quite hideously over the top for the size of company we are. The end users hate to use it, so it was proposed that a light weight web front end would be built to get the users to input their own data, but without having to use SAP directly.

Excluding the fact that the project wasn't properly specified, and has suffered almost constant feature creep, and has woefully inadequate testing, it's actually work quote well, and the end users actually like it!

It's unlike almost any typical Perl/CGI application, but it's built from over 90% CPAN parts. Basically from a static HTML starting page, the user fills stuff in, and POSTs it back to a CGI/Perl script. All the script does is parse the input, place the CGI parameters into an XML structure, and then POST that to the SAP webMethods Business Connector (BC). The BC returns an XML file to the script, which caches it, and sends a redirect to the browser. The browser requests a new page, which calls a new CGI/Perl script, which takes the XML file out of the cache, (maybe tinkers with it), then sends it to the browser after it's been through XSL-T.

Unlike many typical CGI/mod_Perl applications, I'm not using a conventional templating system at all. Indeed except for fatal errors, the CGI process never sends output to the user at all, everything is written into XML files that are then templated for output.

At first having to put things into and take them out of XML structures seems slow compared with a regular Perl hash, but as the systems I'm talking to on each side speak XML, and with XML I can have any data structure I want, and I can change it at will without having to change large chunks of code, has made development time swift (once we had the infrastructure in place).

I would strongly recommend any budding Perl user to have a look on at: