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

Bless you all my fellow monks. (Actually I'm not yet qualified to bless anyone but the thought is there). I wish to ask a question that I have touched on in a previous mailing and I've been impressed with the replies. However, this question is a bit more specific. Is there a standard data format for the input of attribute data into an XML data sheet. I am presuming that tables are used. I use one table for each node type (at a given depth) with the columns representing the different attributes and rows representing replicated occurances of the attribute types for a given element type. I use several of these tables to create the basic XML data display with contents in place and I can then add other elements and attributes easily. Am I breaking any conventions here or is it not something that is standardised?

Title edit by tye

  • Comment on data format for the input of attribute data into an XML data sheet

Replies are listed 'Best First'.
Re: matth
by pg (Canon) on Dec 02, 2002 at 15:39 UTC
    I think DOM will be the best fit for your purpose, and you don't need to reinvent everything by yourself. There is at least one module available for DOM in Perl. Go CPAN check out XML::DOM. You can also do a search, see whether there are other modules.

    As for data structure, as long as it is acceptable to the DOM module you choose, it is fine.
      Do all XML builders from CPAN require Document Type Definitions (DTDs) to do their job?
        As far as I remember, neither XML::DOM nor XML::LibXML (or, to be exact, the respective "Document" subclasses) require a DTD. But you can verify your document against a DTD after you're done building (e. g. XML::LibXML::Document has a method is_valid () which accepts an XML::LibXML::Dtd object).

        pike

Re: data format for the input of attribute data into an XML data sheet
by pike (Monk) on Dec 02, 2002 at 18:14 UTC
    I am not quite sure if your question is

    • how you should structure the XML file,

    • how you can build the XML for printing to a file,

    • or how to read an existing XML file.

    For building and XML file, XML::LibXML and XML::Twig are very convenient. For reading an XML file, consider XML::Twig or XML::Simple (all available from CPAN). You can also use XML::DOM, but I find the above modules easier to handle.

    If none of the above helps you, please rephrase your question.

    pike