ClientSession (beginner-question)

Tuesday, 20 May 2014 · 3 messages · last reply 21 May 2014
CY
Chris Yocum20 May 2014 14:28 #
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi Everyone, I am a bit confused and maybe you can help me. I have a database set up with documents in it and I am attempting to access that through a servlet so I can query the database from a request. However, all I am getting back from the API is the query itself and not the actual results of the query. The stripped down code is below: String query_str = "declare variable $regex as xs:string external; <results>for $x in //entry where $x//*[fn:matches(.,$regex)] order by fn:replace($x, '^(\\d+|\\?|\\s+|\\*|-)+','') return $x</results>";
    ClientSession session = new ClientSession("localhost", 1984, "edil", "********");
    session.execute(new Open("edil"));
    ClientQuery query = session.query(this.query_str);

    query.bind("regex", search);
    String results = query.execute();

    query.close();
    session.close();
The "results" string is the query_str with no binding (just the variable). Have I done someting wrong here? Thank you for your help Chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iF4EAREIAAYFAlN7SmgACgkQDjE+CSbP7HrlvwD/RwRh9oSde0wa2uKqyhERORwy caeD7bcZoy6GlFz0ePsA/RG08Exv/Nmq3Hcbls1YrxjADLO3B4CBYrbx2YmLIKZ4 =oPyO -----END PGP SIGNATURE-----
CG
Christian Grün21 May 2014 10:12 #
Hi Chris, sorry for letting you wait.
Quoted text · Chris Yocum · 1 line
> String query_str = "declare variable $regex as xs:string external; <results>for $x in //entry where $x//*[fn:matches(.,$regex)] order by fn:replace($x, '^(\\d+|\\?|\\s+|\\*|-)+','') return $x</results>";
Your example should work if you use add braces before and after your embedded XQuery expression:
  <results>'wrong'</results>
  <results>{ 'correct!' }</results>
Hope this helps, Christian
Quoted text · Chris Yocum · 23 lines
> ClientSession session = new ClientSession("localhost", 1984, "edil", "********"); > session.execute(new Open("edil")); > ClientQuery query = session.query(this.query_str); > > query.bind("regex", search); > String results = query.execute(); > > query.close(); > session.close(); > > The "results" string is the query_str with no binding (just the > variable). Have I done someting wrong here? > > Thank you for your help > > Chris > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1 > > iF4EAREIAAYFAlN7SmgACgkQDjE+CSbP7HrlvwD/RwRh9oSde0wa2uKqyhERORwy > caeD7bcZoy6GlFz0ePsA/RG08Exv/Nmq3Hcbls1YrxjADLO3B4CBYrbx2YmLIKZ4 > =oPyO > -----END PGP SIGNATURE-----
CY
Chris Yocum21 May 2014 10:20 #
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi Christian, Duh! I had completely forgotten that. Thanks! Chris
Quoted text · Christian Grün · 40 lines
On Wed, May 21, 2014 at 10:12:35AM +0200, Christian Grün wrote: > Hi Chris, > > sorry for letting you wait. > > > String query_str = "declare variable $regex as xs:string external; <results>for $x in //entry where $x//*[fn:matches(.,$regex)] order by fn:replace($x, '^(\\d+|\\?|\\s+|\\*|-)+','') return $x</results>"; > > Your example should work if you use add braces before and after your > embedded XQuery expression: > > <results>'wrong'</results> > <results>{ 'correct!' }</results> > > Hope this helps, > Christian > > > > ClientSession session = new ClientSession("localhost", 1984, "edil", "********"); > > session.execute(new Open("edil")); > > ClientQuery query = session.query(this.query_str); > > > > query.bind("regex", search); > > String results = query.execute(); > > > > query.close(); > > session.close(); > > > > The "results" string is the query_str with no binding (just the > > variable). Have I done someting wrong here? > > > > Thank you for your help > > > > Chris > > -----BEGIN PGP SIGNATURE----- > > Version: GnuPG v1 > > > > iF4EAREIAAYFAlN7SmgACgkQDjE+CSbP7HrlvwD/RwRh9oSde0wa2uKqyhERORwy > > caeD7bcZoy6GlFz0ePsA/RG08Exv/Nmq3Hcbls1YrxjADLO3B4CBYrbx2YmLIKZ4 > > =oPyO > > -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iF4EAREIAAYFAlN8YeAACgkQDjE+CSbP7HpKDgD9E//Gb0+7aMIAjEUnBtDYVK0D T8RtC0EdffPqeLN7de0BALY6aHYAOeHTVxGY7CpMIeQLpPcd2xL8x870lbqososY =6vtL -----END PGP SIGNATURE-----

⚡Generated with XQuery