Posted by: 2stepsback | September 21, 2005

XML Ideas: Programming in XML

Consider this:
All programming languages support blocks.
Ant and Nant are very successful.
So far XML is used only to handle data and transform trees of data from one form to another.
Both Java and .NET aim at platform independence by using an intermediate binary format(Bytecode and IL).
XML is truly cross-platform.

Do you see what i am arriving at?

Yes – why not use xml to write programs using a new language, say xml+, which does all the good things we have come to like in toolslike ant, Nant etc, the processing capacities of xslt and add to it a new programming language – xml+.

Since the source code is XML, it is cross-platform, by definition.

Also, you can generate code in different programming languages by using a <language> tag to specify what language to use – the appropriate source code will be generated and if the user’s system has the compilers of the target languages, the generated source code is fed to the appropriate compiler and object or executable code produced.

e.g.
you can generate Actionscript and make good looking websites
you can generate C/C++/Java and make good programs
you can generate batch files and run OS scripts and so on.

To implement this xml+ compiler, one can use Java/C/C++ since all these have good tokenizing functions and writing some in C/C++ will not be too difficult.

(See http://nwalsh.com/docs/articles/xml2002/lp/paper.html#d0e160)

An example xml+ file will look like this:
<file>
<code-order>
1,2
</code-order>
<code>
<id>1</id>
<include>
<path>stdio.h</path>
<path>stdlib.h</path>
</include>
<class name=”MyClass1″>
<data-member name=”i” type=”int” setget=”yes”>
<data-member name=”j” type=”int” setget=”yes”>
<data-member name=”k” type=”int” setget=”yes”>
<code-member name=”setj” return-type=”int” static=”true”>
<init>
<var name=””>
…..
</init>
<for>
…..
</for>
</code-member>
<code-member name=”getj” return-type=”int” static=”true”>
<init>
<var name=””>
…..
</init>
<for>
…..
</for>
</code-member>
</class>
</code>
<code>
<id>2</id>
<include>
<path>stdio.h</path>
<path>stdlib.h</path>
</include>
<class name=”MyClass2″>
<data-member name=”p” type=”int” setget=”yes”>
<data-member name=”q” type=”int” setget=”yes”>
<data-member name=”r” type=”int” setget=”yes”>
<code-member name=”main” return-type=”int” static=”true”>
<init>
<var name=””>
….. </init>
<for>
….. </for>
</code-member>
<code-member name=”foo” return-type=”int” static=”true”>
<init>
<var name=””>
…..
</init>
<for>
…..
</for>
</code-member>
</class>
</code>
</file>

One more place XML can be very useful is to replace SQL in some cases – although SQL is well understood, universally accepted and easy to learn, you do have several non SQL databases around. Google for “non SQL databases” to get a few. Describing data via conditions like those used in an SQL query seems to be a very logical application for XML.

Advertisements

Categories

%d bloggers like this: