xmlBuf.append("<sql:table xmlns=\"" + SQLModule.NAMESPACE_URI + "\">");
xmlBuf.append("<sql:table xmlns:sql=\"" + SQLModule.NAMESPACE_URI + "\">");
	public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException	{		//was a connection and sql statement specified?		if (args[0].isEmpty() || args[1].isEmpty())            return Sequence.EMPTY_SEQUENCE;				//get the existing connections map from the context		HashMap connections = (HashMap)context.getXQueryContextVar(SQLModule.CONNECTIONS_CONTEXTVAR);		if(connections == null)			return Sequence.EMPTY_SEQUENCE;				//get the connection		long conID = ((IntegerValue)args[0].itemAt(0)).getLong();		Connection con = (Connection)connections.get(new Long(conID));		if(con == null)			return Sequence.EMPTY_SEQUENCE;				try		{			//get the sql statement			String sql = args[1].getStringValue();						//execute the sql statement			Statement stmt = con.createStatement();			ResultSet rs = stmt.executeQuery(sql);						//iterate through the result set building an xml document			StringBuffer xmlBuf = new StringBuffer();			xmlBuf.append("<sql:table xmlns=\"" + SQLModule.NAMESPACE_URI + "\">");						ResultSetMetaData rsmd = rs.getMetaData();			int iColumns = rsmd.getColumnCount();						while(rs.next())			{				xmlBuf.append("<sql:row index=\"" + rs.getRow() + "\">");								//get each tuple in the row				for(int i = 0; i < iColumns; i++)				{					String columnName = rsmd.getColumnName(i);					if(columnName != null)					{						xmlBuf.append("<" + columnName + ">");						xmlBuf.append(rs.getString(columnName));						xmlBuf.append("</" + columnName + ">");					}				}								xmlBuf.append("</sql:row>");			}			xmlBuf.append("</sql:table>");						//return the xml result set			return stringToXML(xmlBuf.toString());		}		catch(SQLException e)		{			throw new XPathException(e.getMessage());		}	}