dragonchild has asked for the wisdom of the Perl Monks concerning the following question:

I'm looking at proposing a single-layout system for all our reports (and possibly exports) where I work. The system is in Perl and I figured that there had to be some CPAN solution out there. However, there are 1095 modules with the word 'Template' in their name. I haven't even started the list for 'Layout'.

The problem is this - I want a single layout from which, given data, I can choose to generate HTML, PDF, XLS, XML, char-delim, fixed-width, etc. Essentially, I want to separate layout from format.

It seems obvious that XML is the way to go, but I wanted to know if there was any other system out there. (Plus, I don't like the speed hit of XSLT to create HTML, which is going to be the most common format used.)

Any suggestions would be greatly appreciated.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

  • Comment on Is XML the only generic layout system out there?

Replies are listed 'Best First'.
Re: Is XML the only generic layout system out there?
by ajt (Prior) on Jan 03, 2003 at 18:37 UTC

    As already mentioned XML isn't a layout system. XML is a markup language that is relativly easy to manipulate with Perl (or any other modern language) and it's easy to convert to other XML and non XML formats via XSLT.

    XML is buzz word compliant, but don't let that put you off, it is a great format to use and Perl has the tools to do the work. With XML you get a nice public standard, so you get lots of documentation both on and off line. While it's verbose, you can read and edit it by hand with a simple text editor - though I would recommend a proper XML editor. My favourite is the XSLT language, while it seems a bit wiered at first it's very powerful, and well documnented too.

    I'd start by looking at XML::LibXML and XML::LibXSLT these are great modules, giving you a powerful XML parser and very fast XSLT processor. Both are well written and based on the excellent and very fast The XML C library for Gnome. Don't think that XSLT is slow, while it's true that the first processors were slow with poor standards support the picture has improved, and it can be done on the fly without big-iron.

    Depending on how sophisticated you want to go, I'd also take a look at the excellent AxKit XML publising suite for Apache. It's based on the LibXML and LibXSLT modules, but adds sophistication and Apache integration as well.

    XSLT can easily handle common XML output forms such as XHTML or RSS/RDF, plain text formats such as CSV/TSV, and produce XSL-FO for conversion to PDF. It may be overkill for your project, but it is a pretty sophisticated set of technologies.

    Good luck!


    --
    ajt
Re: Is XML the only generic layout system out there?
by Sifmole (Chaplain) on Jan 03, 2003 at 18:18 UTC
    XML is not a generic layout system. XML is a Markup Language describing a grammar that you can use to specify a format for documents. XML is born of SGML.

    Currently, the buzzword compliance police state that you should obviously use XML -- but as always it depends on what you need to model.

    If the data is simple, XML may be overkill -- but if want to present via web browsers then XML and XSLT may be the way to go.

Re: Is XML the only generic layout system out there?
by steves (Curate) on Jan 03, 2003 at 18:28 UTC

    I built a system where I work now that separates format from processing. We use it for exports, imports, reports, etc. But it doesn't have at its core any existing format. Instead, it maps inputs to a commom row-oriented object format, provides ways to plug in filters against those objects as they "flow" through a transform, then allows any number of formatting outputs to be placed on the other end.

    So, in short, don't struggle with what format to pick so much as the design of the system. Ours handles XML, HTML, fixed width, delimited, CSV, database tables, formatted text, etc. on either end -- all due to the design's allowance to plug these in easily. I end up mostly using CPAN modules to implement the plug-ins (What can I say, I'm a lazy old guy).

    I'd like to make this generally available at some point but right now it's built on top of some proprietary pieces. If I can just squeeze a few more hours out of the day, maybe I can recreate a clean version on my own time ...

    Also, having recently started using Template::Toolkit I suspect it will now do a lot of what I'm doing (although I like mine now of course!). There are other monks here I see on the TT mailing list so they may have comments on that one.

    Also realize the HTML, XML, etc. are all based on a broader specification known as SGML. At one job there was a movement to specify everything in SGML as a common format. I've never really been convinced of that approach though. Standards change all the time and today's pick may look lousy in a year or two. I much prefer to build flexible systems that allow things to be pulled in and out with ease, and while keeping most clients insulated from the underlying changes.

Re: Is XML the only generic layout system out there?
by Jaap (Curate) on Jan 03, 2003 at 18:35 UTC
    I don't like the speed hit of XSLT to create HTML

    Even if you used another base-format and somehow created methods to convert it to html, pdf etc it would probably have the same speed hit as xsl.

    I'm not that much of a buzzword junky but i would certainly go the XML way because of the amount of tools available for processing XML.