An XML Oriented Programming Language
Yes, a free compiler exists for the first XML oriented language, available
from the Scriptol
site.
But what is a XML oriented language and why has it been designed?
What is an XML oriented programming language?
Scriptol 4 allows to put an XML document into a source code, in a
light form. A light form is just XML without angle-brackets.
Example:
car driver name="Hill" / /carThe XML document is now a data structure, this is as a class, but a lot more flexible. You can describe easily anything with a XML structure. this is a class with unlimited embedding of other classes inside. But what about the methods? We will see that below.
Why XML in source code?
Just to make it a data structure and apply some process on it.
We can also load a real XML document, but a such file has no any statement
in it, this is just data, produced by some tool (word processor, electronic
sheet, database manager, etc...).
The statements are added by the Scriptol code on the model of document
defined in the source code.
A small example describes how to get the minimum of values, it is written
in Scriptol of course:
sheet line name="a" value="125" /
line name="b" value="0" /
line name="c" value="3000"/ /sheet
sheet_instance.sheet.line.at()
while sheet_instance.found()
int x = sheet_instance.getValue("a").toInt()
if x < mininum let minimum = x
let sheet_instance.next() /while
How this works?
To use the XML document, you have to declare an instance of dom. Dom is
a class integrated into Scriptol, and it creates a tree of the document in
memory, that you can access by path of elements or in XML pull mode (event
mode is planed also).
Example:
dom sheet_instance
sheet_instance.build()
The instance is created, and the build() method fills the tree. You
can fill it from scratch also, with the addChild() and addNext() methods.
The advantage of this design is that you can declare several instances
of a document and change the attributes and data, as you can do with
a class.
Lots of methods are available in the DOM class. You can scan the tree in memory
with an iterator.
You can also access the element by their path.
The path is a string of tagnames, similar to a string of identifiers
in object-oriented programming:
Example:
sheet_instance.sheet.line.at()
In detail:
- sheet_instance: the name of the instance.
- sheet: the element "sheet" in the document.
- line: the first sub-element "line" inside the "sheet"
element.
- at(): we want just point out the element, we can use also the getData()
method to return the content, or getValue(attribute-name) to get the
value of an attribute of the element.
Want to learn more?
This is just a taste of XML programming in Scriptol. A documentation is included in the archive of the free Scriptol compiler, and a complete tutorial is provided on the Scriptol site.
A word about Scriptol
Scriptol is a modern, easy to learn programming language. Two free compilers are provided. One compiles a Scriptol source into PHP to interpret it or to make dynamic web pages. It uses the PHP library. The second one compiles into C++ or into native executable, for Windows or Linux. It uses the C++ library and a special library added for compatibility with standard PHP functions.
The author
Denis Sureau is a French engineer and the inventor of the Scriptol programming language, and manager of the Scriptol company. Scriptol exists since 2001, but XML orientation has been implemented in the version 4 (2004) of the language. More innovative improvements are planed for the future.