Good day/night to all. I need to get some advice on how to best deal with reading and writing to possibly unknown XML files.

On my current project, I will be reading and writing 'job request' type information from a queue(s). Sometimes, reading the request is enough, but sometimes they may/will be re-submitted to another queue. At other times, a fresh request will be generated and submitted to a queue for the first time.

In the spirit of flexibility, I'm trying to keep a 'request' and it's destination format as abstract as possible via OOP. A request my live in a text file, it may live in an XML file, a binary file, etc. And it may start life as a text file, and end life as an XML file. That part is pretty straight forward.

Now, down to the XML type of request itself. I can easily verify an XML request is in proper form by validating via a DTD In fact, different requests could have different DTDs. Again, nothing exciting there. Now my question comes down to writing a request. How can I use a DTD to write an XML file given a hash structure of data? I've seen a couple of XML::*Write* modules on CPAN. But nothing clicked in my brain pan in terms of 'That's how to do it'.

Is writing using/through a DTD doc possible, or even reasonable? Would it be better to standardize on one XML doc format, and use XSL/XSLT instead to transform foreign XML requests into and out of the base request DTD format?

I forgot to mention, the queues are also abstracted. A queue may be a directory, a database, a POP3 account, MQueue, etc.

-=Chris


In reply to XML, DTD, and Abstraction of a Data File by jk2addict

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.