System.out.println((String)resource.getContent());
    public static void main( String args[] ) {        try {            Class cl = Class.forName( driver );            Database database = (Database) cl.newInstance();            database.setProperty( "create-database", "true" );            DatabaseManager.registerDatabase( database );                        // get collection            Collection col =                DatabaseManager.getCollection( URI );            // get query-service            XPathQueryService service =                (XPathQueryService) col.getService( "XPathQueryService", "1.0" );                            // set properties            service.setProperty( "pretty", "true" );            service.setProperty( "encoding", "ISO-8859-1" );            service.setProperty( "create-container-elements", "false");                        // execute first query            ResourceSet result = service.query( query1 );			System.out.println(query1 + " found: " + result.getSize());			            XMLResource resource;            ResourceSet result2;            String xml;                        // iterate through the results and execute the second query            // using the current result node as context            for ( int i = 0; i < (int) result.getSize(); i++ ) {                resource = (XMLResource) result.getResource( (long) i );                result2 = ((org.exist.xmldb.XPathQueryServiceImpl)service)                    .query( resource, query2 );                // print the results found by the second query                for( int j = 0; j < (int)result2.getSize(); j++ ) {                    xml = (String)result2.getResource( (long)j ).getContent();                    System.out.println( xml );                }            }        } catch ( Exception e ) {            e.printStackTrace();        }    }