Revision [841]

This is an old revision of EmbeddingXmlsh made by DavidLee on 2009-10-29 18:06:16.

 

Embedding xmlsh


xmlsh is a pure java program and can be embedded into java applications easily.
The easiest way to embed xmlsh is to create an instance of xmlsh command and execute it.
The following is an example of how to invoke xmlsh from within java.

import java.util.ArrayList;
import java.util.List;
import org.xmlsh.core.XValue;
import org.xmlsh.sh.shell.Shell;

class myclass {

// The method executing the task
public void run_xmlsh() throws Exception 
{
	 		
	List<XValue> vargs = new ArrayList<XValue>();
	vargs.add( new XValue("-c"));
	vargs.add( new XValue("xslt -f file.xsl < file.xml" ));
			
	org.xmlsh.commands.builtin.xmlsh cmd = new org.xmlsh.commands.builtin.xmlsh();
			
			
	int ret = cmd.run(null , "xmlsh" , vargs);
	   
 }

}


xmlsh will inherit System.in, System.out and System.err from the current JVM which becomes stdin, stdout and stderr.


There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki