XML as a programming tool
Sean Mc Grath
digitome at iol.ie
Mon Dec 22 17:12:15 GMT 1997
>[walter.kriha at systor.com]
>Force: flexible and adaptive software needs meta-information:
[Much interesting stuff deleted]
Here is a technique we use here that I find *very* useful and *very* general.
Someone out there might find it useful or know a better way to do it.
When building particular configurations - either of software or documents - we
build a "project file" (in XML of course). They all look at bit like this (this
one is for a Document Database):
<Level title = "Company Law">
<Level title = "Companies Acts">
<Level title = "Companies Act 1985">
<file name = "uk85p1">
<Level title = "Auditing Guidelines">
<Level title = "Statements of Accounting Practice">
This is a "configuration" file basically. We might have a dozens of
scripts to run against this project to build different things.
We don't want to have to manage oodles of little
scripts all over the place, most of which need the meta-information.
We tack the scripting stuff on to the configuration file (here using Python):-
<Python name = "Do Something With The Files">
# THis script *knows* about the project file it itself is in
# it is in the Project variable
# Move to the Companies Act 1985 Node
Project.Seek ("Level","title","Companies Act 1985")
flist = GetChildren(...)
# Do something useful
<Python name = "Some Other Interesting Script">
To run a particular script we load this XML file, locate the named Python
Node and Execute its
contents. The loader ensures that the code has acccess to the XML Tree
structure in the variable
This is a bit weird at first sight. A project file that contains the
meta-data about a project
and also the scripting required to operate on the meta-data:-)
I find this hugely useful in practice. Note that the technique relies on the
Python allows you to evaluate a lump of code at run-time. Perl is the same.
Dunno about Java.
Sean Mc Grath
sean at digitome dot com
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
More information about the Xml-dev