Xml Is Canonical

There are pages that presume that XML is the panacea for configuration files. Proponents argue human readability, wide availability of retrieval, parsing, and storage libraries (and other features of XML: schemas, et al.) make the task worthwhile. This reader (who primarily does his work in c/c++) notes that this very often not the simplest thing that could work and that there is a possible technical solution that acknowledges the usefulness of XML while also acknowledging its shortcomings (insomuch as c/c++ is concerned.)

This reader argues that XML could serve as a canonical source used during authorship, storage, and interchange; programs that use configuration data can instead use an XSLT transformed version of the original source. This reader notes that very often configuration need be more complex than a list of name-value pairs. XML could serve as the canonical original.

That is interesting. Would you give a simple example, and suggest some tool sets for CeePlusPlus? -- JohnFletcher

Here is an excerpt of /etc/gaim/prefs.xml (if someone out there has a better example, please put it out there):

 <pref version='1.0' name='/'>
        <pref name='core'>
                <pref name='away'>
                        <pref name='away_when_idle' type='bool' value='1' />
                        <pref name='mins_before_away' type='int' value='5' />
                        <pref name='default_message' type='string' value='Slightly less boring default' />
                        <pref name='auto_reply' type='string' value='awayidle' />
                </pref>

This might translate into:

 [core:away]
 away_when_idle = 1
 mins_before_away = 5
 default_message = Slightly less boring default
 auto_reply = awayidle

Some notes:

As a developer, I know a priori what values I need and what type (e.g. bool, int, string) the values should take. Putting the information in the configuration may be useful for someone looking at the file, but at the end of the day if the program using the configuration needs an int, it will try for an int and fail if the value fails to meet validation criteria.

Presumably I have an XSLT that creates the configuration used by the program from the canonical XML version of the configuration. Similarly, if the configuration is shared between applications, each application can generate a configuration file that is simple for them to use and which includes only relevant information for that application.

I guess this sounds a bit like arm-waving but it continues to work well for my work.

This is different from CanonicalXml in that a normalized XML representation of the work is considered the ultimate source from which derivatives may be created.

Bingo!

See also CanonicalXml


CategoryXml


EditText of this page (last edited January 15, 2007) or FindPage with title or text search