XQDataSource dataSource = getDataSource(); runXQuery(dataSource.newQuery(xquery.toString()));
ShellQuery squery = new ShellQuery(xquery.toString(), this); runXQuery(squery.asXQuery());
    private void runCommand(String line) {        if(line == null || line.length() == 0) {            return;        }        String commandString = null;        String options = null;        if( line.indexOf(' ') == -1 ) {            commandString = line;        } else {            commandString = line.substring(0, line.indexOf(' '));            options = line.substring(line.indexOf(' ')+1);        }		com.marklogic.shell.Command command = null;		try {			String[] path = properties.getStringArray("path");			if( path != null && path.length > 0 ) {				for(int i = 0; i < path.length; i++) {					try {						Class commandClass = Class.forName(path[i] + "." + commandString);						command = (com.marklogic.shell.Command)commandClass.newInstance(); 						break;					} catch(Exception ignored) {						command = null;					}				}			}		} catch(Exception ignored) { }		// Try the default system path as a last attempt.		if( command == null ) {			try {				Class commandClass = Class.forName(SYSTEM_PATH + "." + commandString);				command = (com.marklogic.shell.Command)commandClass.newInstance(); 			} catch(Exception ignored) {				command = null;			}		}        if( command != null) {            try {            		if(options != null && options.length() > 0 && options.charAt(options.length()-1) == ';') {            			options = options.substring(0, options.length()-1);            		}				command.execute(this, options);			} catch(Exception e) {				if(debug()) {					e.printStackTrace();				}                printLine("Failed to run command '" + commandString + "': " + e.getMessage());            }        } else {            StringBuffer xquery = new StringBuffer();            boolean clearBuffer = false;            while( ';' != line.charAt(line.length()-1)) {                if( line.length() >= 2) {                    if( '\\' == line.charAt(line.length()-2) &&                        'c' == line.charAt(line.length()-1)) {                            clearBuffer = true;                            break;                    }                }                xquery.append(line);                try {                    line = console.readLine("   -> ");                    if( line == null || line.length() == 0 ) {                        line = " ";                    }					line = " " + line;                } catch(IOException e) {                    exitWithError(e.getMessage());                }            }            xquery.append(line.substring(0, line.length()-1));            if( !clearBuffer ) {            		try {            			XQDataSource dataSource = getDataSource();					runXQuery(dataSource.newQuery(xquery.toString()));            		} catch(XQException e) {            			printError(e);            		}            }        }    }