I hesitated for a long time before asking this question as it may be considered to far "off topic" or be voted down for any number of other reasons, but after much research and trial by error, I've decided to risk it here where I have a high degree of respect for the accumulated wealth of experience rather than in 'some other forum'!

So here goes: (disables the flushing sound in XPFixation)

The scenario is this. I have a collection of XML files describing various "things". These are stored in a heirarchy of subdirs, loosely grouped by type or subject. The application is to allow users to navigate around the structure and to select the thing of interest and have the details presented on screen using a browser.

With the help of many good monks (and a few bad ones:), I now have the navigation part written in Perl/CGI and am quite pleased with it despite how long it took me to get it to run. I wanted to evaluate Perl for myself anyway.

My problem now is the best way to present the contents of the XML on screen. There seem to be various ways of doing this:

  1. Using XML::Simple and CGI or HTML::Templates or even Jeurd's PLP package which I found very easy and intuative to work with. The problem with this is that the contents of the XML files are not wholey consistant. Some have pictures, some do not. Some have details in attributes that need to be displayed, others have the same details as the contents of nested tags. I do not control these files unfortunately. This approach means re-coding for each new format that comes along.

  2. Basically, I just need to display this stuff on screen. I had thought that I could simply attach a suitable .css file to each xml file and lo, it would take care of itself but that proves to be problematic in several areas.

    • css1 does not provide a mechanism for marking an abitrary tag as a link. This is a "must have" facility.
    • Many browsers do not respond well, if at all to css1 positioning attributes.
  3. I could use the more advanced features of css2.

    • This provides the "arbitrary tag as a link" facility.
    • I don't quite see how to handle the "details as attributes" problem yet.
    • I have discovered that even browsers that claim css2 compatibility (Opera, IE6 etc) still baulk or fall down in lots of areas. I have a list of open support issues raised with Opera on this.
  4. The latest possibility is the use of XSLT & XPATH. I brought the book. And it certainly could be used to acheive my goal. The downsides of this are:

    • It requires another tool to perform the transform to XHTML. There are several of these available both commercial and freeware. I haven't discovered (or yet looked) for one written in Perl. I am sure that there will be one soon if not already.
    • It would require learning Yet Another Syntax in order to write the XSL stylesheets for each variation of the input XML. This may or may not be easier than doing the transform in with Perl/XML::Simple?

What I'm hoping from this post is that one or two peope here have already been down this road and will share their experience, choices and reasoning with me so as I can short-cut a little of the redundant learning that will result from me investigating each of them myself.

Thanks for your time in reading this.


In reply to Request for advice. Presenting XML. by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.