if (tostring) { ByteArrayOutputStream out = new ByteArrayOutputStream (); XmlWriter writer = new XmlWriter (out, "UTF-8"); writer.setDatabaseMode(false); boolean result = writer.write(node); writer.close(); return new ESString (out.toString ("utf8")); } else { File tmpFile = new File(arguments[0].toString()+".tmp."+XmlWriter.generateID()); XmlWriter writer = new XmlWriter (tmpFile); writer.setDatabaseMode(false); boolean result = writer.write(node); writer.close(); File finalFile = new File(arguments[0].toString()); tmpFile.renameTo (finalFile); this.evaluator.reval.app.logEvent("wrote xml to " + finalFile.getAbsolutePath() ); }
File tmpFile = new File(arguments[1].toString()+".tmp."+XmlWriter.generateID()); XmlWriter writer = new XmlWriter (tmpFile); writer.setDatabaseMode(false); boolean result = writer.write(node); writer.close(); File finalFile = new File(arguments[1].toString()); tmpFile.renameTo (finalFile); this.evaluator.reval.app.logEvent("wrote xml to " + finalFile.getAbsolutePath() );
		public ESValue callFunction(ESObject thisObject, ESValue[] arguments) throws EcmaScriptException {			if ( arguments==null ||					(tostring && arguments.length != 1) ||					(!tostring && arguments.length != 2))				throw new EcmaScriptException("wrong number of arguments");			INode node = null;			try	{				node = ((ESNode)arguments[0]).getNode();			}	catch ( Exception e )	{				// we definitly need a node				throw new EcmaScriptException("first argument is not an hopobject");			}			try	{				if (tostring) {					ByteArrayOutputStream out = new ByteArrayOutputStream ();					XmlWriter writer = new XmlWriter (out, "UTF-8");					writer.setDatabaseMode(false);					boolean result = writer.write(node);					writer.close();					return new ESString (out.toString ("utf8"));				} else {					File tmpFile = new File(arguments[0].toString()+".tmp."+XmlWriter.generateID());					XmlWriter writer = new XmlWriter (tmpFile);					writer.setDatabaseMode(false);					boolean result = writer.write(node);					writer.close();					File finalFile = new File(arguments[0].toString());					tmpFile.renameTo (finalFile);					this.evaluator.reval.app.logEvent("wrote xml to " + finalFile.getAbsolutePath() );				}			}	catch (IOException io)	{				throw new EcmaScriptException (io.toString());			}			return ESBoolean.makeBoolean(true);        }