Configuration hierarchy organization

K

Kenneth Porter

I'm trying to organize the XML for my system configuration.

I have a System (top-level object) comprising a varying number of
Components, each with its own configuration. I also have a number of
classes representing stateful bundles of related methods. The latter
classes need per-component configuration. Should that configuration be
grouped with each Component's configuration, or should it be stored with
the configuration for each bundle of stateful methods? What are the pros
and cons of each?

Here's a "picture" of the runtime organization:

class System
{
Container<Component> components;
StatefulMethodBundle1 group1;
StatefulMethodBundle2 group2;
};

What are the relative advantages of storing a parameter in these ways?

System.component[x].group1.y

versus

System.group1.component[x].y

(x is the name (string) of a component, y is a component-specific parameter
needed by group1.)
 
M

mczard

System.component[x].group1.y
versus
System.group1.component[x].y

Which solution to choose depends on what is changed together more
often. You should organize the config so that typical changes will
affect parts of configuration that are close to each other in the XML.
I suppose typical changes more often affect many methods and a single
component, so I think the first solution is better.

Moreover, you seem to be using a language that was designed for text
annotations, not for data. If your application is not text-oriented,
but rather data-oriented better use Harpoon (http://
harpoon.sourceforge.net) or Yaml (http://yaml.org), but not the XML.
 
J

Joseph Kesselman

Uhm... As the example you show demonstrates, this isn't an XML question;
it's a basic data structures question.
 
K

Kenneth Porter

Uhm... As the example you show demonstrates, this isn't an XML question;
it's a basic data structures question.

Pointers to better forums would be welcome.
 
K

Kenneth Porter

(e-mail address removed) wrote in @t1g2000pra.googlegroups.com:
Moreover, you seem to be using a language that was designed for text
annotations, not for data. If your application is not text-oriented,
but rather data-oriented better use Harpoon (http://
harpoon.sourceforge.net) or Yaml (http://yaml.org), but not the XML.

I wasn't aware of those when I started to code. Thanks for the pointers.

The app is implemented in C++, and uses the XML classes in the wxWidgets
frame work to parse its config files.

One thing I haven't seen in any of the data languages is a way of
implementing "macros", a way to express a sequence that is used in several
places. For example, my config file defines multiple types of systems
(selected at runtime by the user) and many characteristics of these systems
are common (eg. they may share similar collections of components). It would
be desirable to specify a component configuration once and then refer to it
in several places. I've seen hints of XML "pointers" that might serve the
purpose, but haven't found any good examples illustrating their use.
 
K

keshlam

One thing I haven't seen in any of the data languages is a way of
implementing "macros"

If you're working with DTDs rather than schemas, Parsed Entities do
the job. Unfortunately DTDs are incompatable with namespace-aware
processing, and thus nearly unusable in modern XML applications.

The XPointer and XInclude specs provide a more modern solution... but,
alas, aren't as widely supported as one would like. The usual
workaround is to preprocess the document through an XSLT stylesheet
which implements the basic behavior of XInclude, or to implement your
own include mechanism when designing your XML processing code.
 
K

Kenneth Porter

The XPointer and XInclude specs provide a more modern solution... but,
alas, aren't as widely supported as one would like. The usual
workaround is to preprocess the document through an XSLT stylesheet
which implements the basic behavior of XInclude, or to implement your
own include mechanism when designing your XML processing code.

I was thinking of taking the latter approach. Have any frameworks made
progress in this direction? Or is there any reference code implementing
XPointer or XInclude? I could then incorporate it into wxWidgets (the
framework I'm using, which uses Expat under the hood).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top