Re: external java agent calls functions in o:XML

Martin Klang <[email protected]> Tue, 13 Feb 2007 01:17:29 +0100
Newsgroups gmane.text.xml.o-xml
Message-ID <[email protected]>
Francisco,


thanks for your mail and answers - never is too late! Spam is the  
dregs, eh. I'll post you this as a separate mail as well.


You can compile a program, look up and call a function like this ->

import org.oXML.type.*;
import org.oXML.engine.*;
...
String systemId = "your-file.oml";
Name functionName = new Name("your-function");
Type[] signature = new Type[]{}; // default sig, ie your-function()
Node[] args = new Node[]{}; // empty args
...
ProgramFactory pfactory = new ProgramFactory();
pfactory.loadDefaultExtensions();
InterpretedProgram program = pfactory.getProgram(systemId);
pfactory.compile(program);
Function func = program.getResolver().getFunction(functionName,  
signature);
RuntimeContext env = new RuntimeContext(program);
Node result = func.invoke(args, env);
String stringResult = result.stringValue();


If your function has a different signature then the args have to  
match too. You can create Nodes for args with simple constructors, eg  
new StringNode("hello"), new NumberNode(5.0) etc.


Your questions:

> 1) After o:xml is interpterted by objectbox, how can the return  
> value or methods be exposed or acquired to the java agents?

You can get the return value of a single function as per above. You  
can also execute the whole program:
Node result = program.run(env);

> 2) After the functions in o:xml are executed, the associated value  
> of variables should be changed, but will the changes be shown in  
> oxml file or just in memory?

o:XML program files don't change when you run the program, just like  
Java source files don't change when you run a Java program. You could  
of course write to/from a file (even the program file, if you really  
want) or another datastore, eg a database.

> 3) Could you please kindly present an example to show how to use  
> objectbox to "randomly" invoke the methods/functions in o:xml

see above.

>  4) Are there source codes available for objectbox?

ObjectBox is published under the Gnu GPL. You can download the source  
here:
http://www.o-xml.org/download/

And you can browse the Java API here:
http://www.o-xml.org/docs/java-api/


Hope this helps! Pls ask again if you require more help or advice, or  
if you have other feedback.


/m

On 12 Feb 2007, at 18:00, Francisco wrote:

> Dear Martin,
>
> To my surprise, today I find your reply email dated weeks ago to me  
> in the bulk folder again. I was looking forward to hearing from you  
> on this. But I didn't receive on time. Hope it is not late to  
> continue our discussion. And I am still very keen to have your help  
> in providing an example.  During the period of time without seeing  
> your email, I am very keen to get some breakthrough with o:xml. I  
> did some work and further thinking of o:xml.