comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: Use of XML for config files
Date: 18 Jun 2002 15:11:39 -0400
Date: 2002-06-18T19:19:28+00:00	[thread overview]
Message-ID: <uofe8xuz8.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: aentlc$cd3$1@a1-hrz.uni-duisburg.de

Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de> writes:

> Darren New <dnew@san.rr.com> wrote:
> : val := conf.get("Section", "super.subkey", "default value goes here");
> 
> Fine except that you make a decision to limit us to
> no subsections unless you allow "Section.Subsection"?
> A la
> 
>   section_specification ::= section_name { "." section_name }
> 
> :  I'm
> : trying to see what XML would be supporting that you can't support easily in
> : the INI format.
> 
> (I'm guessing that if we go on, you would be demonstrating
> that by building special syntax into the keys in an INI file
> you could do pretty much anything that can be done with XML? :-)

If you are modifying the INI file format by adding "." to keys, that's
not the INI file format, and we might as well use the Java property
format (which I did in my latest implementation).

Please look at that and see if you like it.

> Actually I'm fond of something like restricted XPath expressions.
> They need not necessarily look like XPath expressions, I'm thinking
> of a 1:1 mapping, if the (hidden) mechanism uses XML. This way we
> could have a sectioning depth as needed by the application, but it
> would always look like a dictionary lookup.

Yes.

> Unless I want all configuration data for one subsection or one item,
> for which see below.

I didn't implement this, but it is in the requirements (return a list
of the next-level items at a given level).

> For an example of what cannot easily be done in INI format, the
> distinction between values that are in fact properties of items
> (like in the brush example) and values for "stand alone" items (to
> me) are not really explicit in k=v, unless the dot has this meaning.
> But when does a '.' have this meaning? For example in a.b.c, what
> meaning does the first dot have what meaning has the second? Aren't
> you introducing context dependent meanings of the symbol '.'?

I see the distinction, but I'm not clear when it is relevant. Since
the application has to know the name and type of everything in the
config file, it knows what to ask for all the time.

> How many lines would you have to read for brush.xxx? How do you know
> that when you have found brush.xxx lines and the pen.xxx lines,
> there will be no more brush.xxx line after the pen.xxx lines? 

Requirement 16; data retrieval is independent of the key order in the
file. So the in-memory copy of the data has to group all the brush.xxx
values together; I used a tree structure.

> You whould have to keep track of them all, afaics, in a sorted map?

Yes, or a tree. Some sort of ordered structure is required.

> Or use some equivalent mechanis. If I use valid XML configuration
> data, then by previous validation (if it has taken place), the brush
> node and only the brush node below the tools node will contain all
> properties of the brush.

That is a requirement on the file format. But we actually need a
requirement on the in-memory copy. That turns out to be easier.

> You cannot but by discipline require that there be only one
> brush setting in exactely one tools section, can you? (That is,
> the mechanics for dealing with conf data would have to check
> this, which is another programming task for INI files, to some
> extent mimiccing XML validation; this _could_ be different for
> XML because you can couple your product with a tailored conf
> editing component sold to your customer (such things exist :-)
> See below for hand editing).

Requirement 17; multiple copies are allowed on read (last one is
saved). Only one is written.

Presumably, when the app writes the config file, it will be properly
sorted and/or grouped.

> If conf values are big, will your customers be happy to have to edit
> overly long lines? Would they be able to do that with Wordpad? And
> without destructive effects? (I've elsewhere mentioned the problems
> induced by line breaks.)

Yes, I'm not clear whether we should allow/require multi-line values
with the Java properties format. I would hope that there are no
"overly long values" in a config file. In general, my approach to
binary data like pictures would be to put the path to the picture file
in the config file. Do you have an example where that is not the right
approach? 

> OTOH, as Stephen mentions on his page, XML hand editing requires
> knowledge of XML Syntax. But the issue (for me) here is that you can
> get _any_ non-idiot-proof syntax wrong. I doubt that there is an
> idiot-proof way of dealing with this problem. (I'm not excluding
> myself from the set of idiots here, I do use parsers :-)

I'll settle for novice-proof :). Clearly, it is harder to screw up the
Java property syntax than the XML syntax. We have to assume some level
of competence on the part of the user.

> How are the configuration values stored internally? In a hash table
> indexed by dotted names? 

It's up to the implementer. The API requirements don't actually say,
but my example implementations say keys are dotted names, and the
internal format is a tree.

> This would require repeated "parsing", for example if I wanted to
> write out anything having to do with brushes, since I have to look
> for the "tools.brush" prefix. Right? 

Yes. Although if you use a hash table on the full key, you are not
"parsing", you are "hashing".

My implementations do "parse" the keys for each lookup. That was easy
to do; if it turns out to be to slow, somebody can do a hash table or
something else.

> If the values are stored in an tree, wouldn't this effort in effect
> start building DOM support for INI files? :-)

Yes. I think that's implied by the current requirements.

> : So what are you suggesting the XML-based API should look like?
> 
> It should make no mention of XML, of course :-).
> 
> My idea is that ideally (o.K., whatelse is an idea! :-)
> it is an option to choose a format and/or provide
> for functionality to convert between them, if that is possible
> (for example it is possible in one direction from INI->XML;
> the opposite might not be easily done because applications
> might have to be partly rewritten to cope with nested sections.)

I prefer one standard file format, so different apps can share them,
and people get used to editing one format, and the implementation code
gets tested more.

If your app outgrows the Config_File spec, and you need XML, you can
convert the files once, and start using a real XML parser.

-- 
-- Stephe



  reply	other threads:[~2002-06-18 19:11 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-03 11:48 Use of XML for config files Mike and Lynn Card
2002-06-03 17:42 ` Pascal Obry
2002-06-04  6:26 ` Volkert Barr
2002-06-04 12:47   ` SteveD
2002-06-04 13:51     ` Volkert Barr
2002-06-04 19:29   ` Ted Dennison
2002-06-05  7:18     ` Volkert Barr
2002-06-05 10:24       ` Georg Bauhaus
2002-06-05 11:35         ` Preben Randhol
2002-06-05 14:52           ` Georg Bauhaus
2002-06-05 15:22             ` Preben Randhol
2002-06-05 19:11             ` Darren New
2002-06-06 13:38               ` Georg Bauhaus
2002-06-06 15:06                 ` Darren New
2002-06-07 11:28                   ` Georg Bauhaus
2002-06-07 17:10                     ` Darren New
2002-06-06  6:48           ` Volkert Barr
2002-06-06 13:27             ` Georg Bauhaus
2002-06-05 14:41       ` Robert C. Leif
2002-06-09 22:00     ` Stephen Leake
2002-06-10 15:03       ` Ted Dennison
2002-06-10 18:12         ` Stephen Leake
2002-06-12 11:25         ` Georg Bauhaus
2002-06-12 15:33           ` Darren New
2002-06-12 17:53             ` Stephen Leake
2002-06-13 14:18               ` Ted Dennison
2002-06-13 16:36                 ` Stephen Leake
2002-06-14  3:27                   ` Ted Dennison
2002-06-14 15:54                     ` Stephen Leake
2002-06-12 19:18             ` Georg Bauhaus
2002-06-13 13:53             ` Ted Dennison
2002-06-13 15:26               ` Georg Bauhaus
2002-06-13 16:39               ` Darren New
2002-06-13 17:06                 ` Georg Bauhaus
2002-06-13 17:43                   ` Darren New
2002-06-14 15:56                     ` Georg Bauhaus
2002-06-13 17:54                 ` Georg Bauhaus
2002-06-13 18:31                   ` Darren New
2002-06-14 16:04                     ` Stephen Leake
2002-06-14 16:48                       ` Darren New
2002-06-14 17:03                     ` Georg Bauhaus
2002-06-14 17:22                       ` Darren New
2002-06-18 15:20                         ` Georg Bauhaus
2002-06-18 15:37                           ` Darren New
2002-06-18 18:20                             ` Georg Bauhaus
2002-06-18 19:11                               ` Stephen Leake [this message]
2002-06-18 21:47                               ` Darren New
2002-06-19 11:31                                 ` Georg Bauhaus
2002-06-19 15:13                                   ` Stephen Leake
2002-06-19 21:14                                     ` Georg Bauhaus
2002-06-20 14:38                                       ` Stephen Leake
2002-06-20 16:02                                         ` Georg Bauhaus
2002-06-20 20:37                                           ` Stephen Leake
2002-06-21 16:24                                             ` Ted Dennison
2002-06-24 14:11                                               ` Stephen Leake
2002-06-19 16:43                                   ` Darren New
2002-06-19 20:33                                     ` Georg Bauhaus
2002-06-12 17:48           ` Stephen Leake
2002-06-13  7:42             ` Tarjei T. Jensen
2002-06-13 13:53               ` Georg Bauhaus
2002-06-13 14:10               ` Stephen Leake
2002-06-13 16:50                 ` Warren W. Gay VE3WWG
2002-06-13 17:31                   ` Tarjei Tj�stheim Jensen
2002-06-14 16:11                   ` Stephen Leake
2002-06-13 17:28                 ` Tarjei Tj�stheim Jensen
2002-06-19  9:48                   ` Preben Randhol
2002-06-10 14:45     ` Georg Bauhaus
2002-06-09 21:52   ` Stephen Leake
2002-06-10  0:02     ` Preben Randhol
2002-06-10 12:42       ` Stephen Leake
2002-06-10 16:21         ` Pascal Obry
2002-06-12 11:29           ` Georg Bauhaus
  -- strict thread matches above, loose matches on Subject: below --
2002-06-05  7:33 Grein, Christoph
2002-06-05  7:59 ` Volkert Barr
2002-06-05  8:25 Grein, Christoph
2002-06-05  8:39 ` Volkert Barr
2002-06-05  9:31 ` Manuel Collado
2002-06-05 10:01   ` Volkert Barr
2002-06-05 10:02 Grein, Christoph
2002-06-09 22:13 ` Stephen Leake
2002-06-10  1:42   ` Darren New
2002-06-10 12:46     ` Stephen Leake
2002-06-10 15:52       ` Darren New
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox