Introduction to o:XML

Object oriented programming is facilitated by o:XML while being a markup language. o:XML is an object oriented programming language and also a markup language. With the o:XML you can create program codes easily with the objected oriented features. The paradigms of object orientation are also present in this programming language.


_______________________________________________



You can use an UML editor to generate the programming codes in o:XML or use any XML editor to write your code for o:XML. The output of an o:XML program could be an XML document itself. Using appropriate transformation engines you can convert your o:XML programs to produce codes in Java or C++. There is an interpreter called ObjectBox which can be used to interpret your o:XML code and produce output directly without using a transformation engine. This is the workflow for o:XML programming.

Let us look at a simple program in o:XML which will give you an idea about programming in o:XML.

<?xml version="1.0"?>
<o:program>
<o:type name="MyProgram">
<o:function name="DisplayText">
<o:do>
<o:return select="'Hi, this is my first program in oXML'"/>
</o:do>
</o:function>
</o:type>
<o:set instMP="MyProgram()"/>
<o:eval select="$instMP.DisplayText()"/>
</o:program>

In the above program you can see that the structure of the program is the same as an XML document. The root node for this program is the element <o:program>. Classes of objects in o:XML are called Types. These Types are nodes in o:XML. In the above example you can see a Type identified by “MyProgram”. Since ‘Types’ are classes you need to create an instance of the class before you can work on it. To create an instance you can use the element <o:set> as given in the above example. The line of code “<o:set instMP="MyProgram()"/>” creates an instance of Type MyProgram called “instMP”. Like you have methods within classes you can have functions within Types. A function named “DisplayText” is given in the above example which is used to display the text “Hi, this is my first program in oXML”. The line of code in the program, <o:eval select="$instMP.DisplayText()"/>, is used to call the function DisplayText to display the text. Within the function “DisplayText”, an <o:do> element is used to perform some action. In this example we are just using the element <o:return> to return the text that needs to the displayed.

We have already said that the output of an o:XML program is in the form of an XML document, you can use this output to produce any type of content for display using a transformation engine. Let us see an example to produce an XML node from o:XML. Suppose you want to create an XML node with some attribute like,

<book author=”Peter” price=”340”>
Handling stress at workplace
</book>

The code for creating the above XML node in o:XML would be something like,

<o:element name="book">
<o:attribute name="author" select="'Peter'"/>
<o:attribute name="price">340</o:attribute>
Handling stress at workplace
</o:element>

The element <o:element> is used in o:XML to create elements in the output of the program. The element <o:attribute> is used to create the attributes for the elements created. You may note that the attributes are created in two different ways. You can use the ‘select’ attribute of the element <o:attribute> to assign a value to the attribute of the output XML. It is also possible to enclose the value of the attribute using the <o:attribute>’s opening and closing tags.

All the programming features of other languages along with object orientation paradigms are possible in o:XML. Conditional looping or display of values are done using the elements like <o:if>, <o:choose>, and <o:while>. Consider the statements given below:

<o:choose>
<o:when test="$opt = 1">
<o:log msg="You selected option ONE."/>
</o:when>
<o:when test="$opt = 2">
<o:log msg="You selected option TWO"/>
</o:when>
<o:otherwise>
<o:log msg="You have NOT selected any option."/>
</o:otherwise>
</o:choose>

The <o:choose element of the o:XML programming language is similar to the ‘Select’, ‘Case’, ‘End Select’ statement for conditional processing of statements in other programming languages. In the example given above the condition is checked using the <o:when> element. If the condition is True the statement enclosed within that <o:when> element is executed otherwise the next is statement is checked. The conditions are checked until the first True condition is encountered. If none of the conditions are True then the statement within the <o:otherwise> element is executed. The <o:log> element is used to log messages during program execution. The o:XML engine ObjectBox has features to log messages during runtime.

Exception handling is one of the important features of object oriented programming that is necessary for efficient programming. This feature is supported in o:XML by the elements, <o:throw> and <o:catch>. Upon checking a condition or state the <o:throw> element is used to throw an exception and that exception is caught by the <o:catch> element.

For applications to perform efficiently concurrent executions using threads are done. Threads are supported by o:XML using the element <o:thread>. The element <o:set> is used to initiate a thread and to pass on execution to other statements.

<o:set thread="SomeFunction()"/>

The above statement initiates a function called ‘SomeFunction’ as a thread and the execution goes to the next statement. There are many other programming statements in o:XML as found in other Object Oriented Programming languages. You can refer to the url http://www.o-xml.org/ for more details of the o:XML programming language. With its functionality and ease of use we can expect that the o:XML as a markup language and programming language would take XML programming to higher levels in the future.



_______________________________________________

FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.

Name:
Email:

Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.

_______________________________________







FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.

 

 

Add to My Yahoo!

Visit XML Training Material Guide Homepage

 

 

Copyright - © 2004 - 2017 - All Rights Reserved.