Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Config Files Redux

by traveler (Parson)
on Nov 23, 2006 at 22:02 UTC ( #585797=note: print w/replies, xml ) Need Help??


in reply to Config Files Redux

Thanks for the comments so far. I have discovered a few things: 1) I really don't expect anyone except developers and maintainers to edit configuration files directly; I expect some program to manage "user" changes. 2) If I have a large file, I prefer XML with a DTD because it can help prevent size=blue or color=large type mistakes; that's good even if machine-generated in error. 3) Most of us agree that XML should be edited by good tools (presumably not just vim...).

Replies are listed 'Best First'.
Re^2: Config Files Redux
by chromatic (Archbishop) on Nov 24, 2006 at 05:37 UTC
    I prefer XML with a DTD because it can help prevent size=blue or color=large type mistakes...

    You've said this multiple times, but you've never explained how.

    The how is the same way you would do it for any other type of file. Someone writes a comprehensive set of rules by which to validate the configuration file. The file format doesn't matter. The format of the rules doesn't matter. Something reads and processes the configuration file and the rules and applies the rules to the processed file.

    You have to do this anyway to parse the configuration file in your application.

    Now you may have better tools to do this with an XML application than with any other format, but then your real argument for using XML is better tools, not validation.

      And tools like this exist for formats like YAML; for example you can use kwalify to produce a DTD-like schema for YAML documents.

      If the DTD is a tool, then yes, the issue is better tools. The way to do it in a DTD is:
      <!ATLIST box color (red|blue|green) blue>
      This allows
      <box color=red />
      but not
      <box color=large />
      The default is blue in this example.

        Pity that's not XML, though.

        Worse, it means that everyone who edits the configuration file either forgoes validation or has to use an XML-aware editor. There goes scriptability and so many of the lovely Unix administration tools we've grown to love over the past few decades.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://585797]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2021-10-22 12:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?