OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: XML as a programming tool

[ Lists Home | Date Index | Thread Index ]
  • From: Sean Mc Grath <digitome@iol.ie>
  • To: xml-dev@ic.ac.uk
  • Date: Mon, 22 Dec 1997 17:12:01 GMT

>[walter.kriha@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):

<FinancialInformationDatabase>
 <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
different processing
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">
<[CDATA[
        # 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>
<Python name = "Some Other Interesting Script">
<[CDATA[
...
]]>
</Python>
</FinancialInformationDatabase>

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
"Project".

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
fact that
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@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS