Re: external java agent calls functions in o:XML
Francisco <jshzhang2000-/[email protected]> Wed, 14 Feb 2007 06:38:20 +0000 (GMT)
| Newsgroups | gmane.text.xml.o-xml |
|---|---|
| Message-ID | <[email protected]> |
--===============0187508191== Content-Type: multipart/alternative; boundary="0-1123009012-1171435100=:74434" Content-Transfer-Encoding: 7bit --0-1123009012-1171435100=:74434 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Dear Martin, =20 Thank you so much for your kind reply. I appreciate very much. I will car= ry on a test based on your suggestion and definitely will go back to you.= =20 =20 I am planning to link database with o;xml, but I am wondering if the co= nventional SQL database or newer Object-oriented DB (e.g., Cache) are all= supported by o:xml?=20 =20 Millions of thanks, =20 Kind regards, Francisco =20 Martin Klang <[email protected]> wrote: Francisco, thanks for your mail and answers - never is too late! Spam is the=20 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 =3D "your-file.oml"; Name functionName =3D new Name("your-function"); Type[] signature =3D new Type[]{}; // default sig, ie your-function() Node[] args =3D new Node[]{}; // empty args ... ProgramFactory pfactory =3D new ProgramFactory(); pfactory.loadDefaultExtensions(); InterpretedProgram program =3D pfactory.getProgram(systemId); pfactory.compile(program); Function func =3D program.getResolver().getFunction(functionName,=20 signature); RuntimeContext env =3D new RuntimeContext(program); Node result =3D func.invoke(args, env); String stringResult =3D result.stringValue(); If your function has a different signature then the args have to=20 match too. You can create Nodes for args with simple constructors, eg=20 new StringNode("hello"), new NumberNode(5.0) etc. Your questions: > 1) After o:xml is interpterted by objectbox, how can the return=20 > 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=20 can also execute the whole program: Node result =3D program.run(env); > 2) After the functions in o:xml are executed, the associated value=20 > of variables should be changed, but will the changes be shown in=20 > oxml file or just in memory? o:XML program files don't change when you run the program, just like=20 Java source files don't change when you run a Java program. You could=20 of course write to/from a file (even the program file, if you really=20 want) or another datastore, eg a database. > 3) Could you please kindly present an example to show how to use=20 > 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=20 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=20 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=20 > in the bulk folder again. I was looking forward to hearing from you=20 > on this. But I didn't receive on time. Hope it is not late to=20 > continue our discussion. And I am still very keen to have your help=20 > in providing an example. During the period of time without seeing=20 > your email, I am very keen to get some breakthrough with o:xml. I=20 > did some work and further thinking of o:xml. =09 --------------------------------- New Yahoo! Mail is the ultimate force in competitive emailing. Find out = more at the Yahoo! Mail Championships. Plus: play games and win prizes. --0-1123009012-1171435100=:74434 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable <div>Dear Martin,</div> <div><BR>Thank you so much for your kind reply. = I appreciate very much. I will carry on a test based on your su= ggestion and definitely will go back to you. </div> <div> </div> <= div>I am planning to link database with o;xml, but I am wondering if= the conventional SQL database or newer Object-oriented DB= (e.g., Cache) are all supported by o:xml? </div> <div>&n= bsp;</div> <div>Millions of thanks, <BR></div> <d= iv>Kind regards,<BR>Francisco</div> <div><BR><B><I>Martin Klang <mart= [email protected]></I></B> wrote:</div> <BLOCKQUOTE class=3Dreplbq style=3D= "PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Fra= ncisco,<BR><BR><BR>thanks for your mail and answers - never is too late! = Spam is the <BR>dregs, eh. I'll post you this as a separate mail as well.= <BR><BR><BR>You can compile a program, look up and call a function like t= his -><BR><BR>import org.oXML.type.*;<BR>import org.oXML.engine.*;<BR>...<BR>String systemId = =3D "your-file.oml";<BR>Name functionName =3D new Name("your-function");<= BR>Type[] signature =3D new Type[]{}; // default sig, ie your-function()<= BR>Node[] args =3D new Node[]{}; // empty args<BR>...<BR>ProgramFactory p= factory =3D new ProgramFactory();<BR>pfactory.loadDefaultExtensions();<BR= >InterpretedProgram program =3D pfactory.getProgram(systemId);<BR>pfactor= y.compile(program);<BR>Function func =3D program.getResolver().getFunctio= n(functionName, <BR>signature);<BR>RuntimeContext env =3D new RuntimeCont= ext(program);<BR>Node result =3D func.invoke(args, env);<BR>String string= Result =3D result.stringValue();<BR><BR><BR>If your function has a differ= ent signature then the args have to <BR>match too. You can create Nodes f= or args with simple constructors, eg <BR>new StringNode("hello"), new Num= berNode(5.0) etc.<BR><BR><BR>Your questions:<BR><BR>> 1) After o:xml i= s interpterted by objectbox, how can the return <BR>> value or methods be exposed or acquired to the java agents?<BR><BR>You c= an get the return value of a single function as per above. You <BR>can al= so execute the whole program:<BR>Node result =3D program.run(env);<BR><BR= >> 2) After the functions in o:xml are executed, the associated value = <BR>> of variables should be changed, but will the changes be shown in= <BR>> oxml file or just in memory?<BR><BR>o:XML program files don't c= hange when you run the program, just like <BR>Java source files don't cha= nge when you run a Java program. You could <BR>of course write to/from a = file (even the program file, if you really <BR>want) or another datastore= , eg a database.<BR><BR>> 3) Could you please kindly present an exampl= e to show how to use <BR>> objectbox to "randomly" invoke the methods/= functions in o:xml<BR><BR>see above.<BR><BR>> 4) Are there source code= s available for objectbox?<BR><BR>ObjectBox is published under the Gnu GP= L. You can download the source <BR>here:<BR>http://www.o-xml.org/download/<BR><BR>And you can browse th= e Java API here:<BR>http://www.o-xml.org/docs/java-api/<BR><BR><BR>Hope t= his helps! Pls ask again if you require more help or advice, or <BR>if yo= u have other feedback.<BR><BR><BR>/m<BR><BR>On 12 Feb 2007, at 18:00, Fra= ncisco wrote:<BR><BR>> Dear Martin,<BR>><BR>> To my surprise, to= day I find your reply email dated weeks ago to me <BR>> in the bulk fo= lder again. I was looking forward to hearing from you <BR>> on this. B= ut I didn't receive on time. Hope it is not late to <BR>> continue our= discussion. And I am still very keen to have your help <BR>> in provi= ding an example. During the period of time without seeing <BR>> your e= mail, I am very keen to get some breakthrough with o:xml. I <BR>> did = some work and further thinking of o:xml.<BR><BR></BLOCKQUOTE><BR><p>  <hr size=3D1>=20 New Yahoo! Mail is the ultimate force in competitive emailing. Find out m= ore at the <a href=3D"http://uk.rd.yahoo.com/mail/uk/taglines/yahoo_co_uk= /championships/games/*http://uk.rd.yahoo.com/evt=3D44106/*http://mail.yah= oo.net/uk/">Yahoo! Mail Championships</a>. Plus: play games and win prize= s. --0-1123009012-1171435100=:74434-- --===============0187508191== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ o-xml mailing list o-xml-zRfLyl9bSvv/[email protected] http://lists.pingdynasty.com/mailman/listinfo/o-xml --===============0187508191==--