Hi,
Im writing a Java program to execute an XQuery using the BaseX QueryProcessor class, and need to pass an XML document as context node.
As far Ive found in the documentation and java examples, this is done with the context() method of QueryProcessor, which receives an instance of the Value class as parameter.
But the examples available are about passing simple types (strings o numbers) but nothing about passing an XML node.
My question is: Where can I find examples or documentation on how to pass XML nodes as parameters to QueryProcessor.context() ?
Thanks for all your help,
William David Velásquez Creativo de Software Creativos Digitales S.A.S. Calle 30A # 83 - 53 Local 1033 Tel: 322 1730 - 311 709 8421 Medellín, Colombia
¿Necesita Integrar Sistemas? Conozca nuestra solución de Integración no Invasiva: http://creativosdigitales.co http://creativosdigitales.co
¿Preguntas sobre Facturación Electrónica? Visite: http://facturasyrespuestas.com/ http://facturasyrespuestas.com
Hi William,
Here’s one way to do this:
Context ctx = new Context(); IO input = new IOContent("<xml/>"); DBNode node = new DBNode(input); try(QueryProcessor qp = new QueryProcessor(".", ctx).context(node)) { System.out.println(qp.value()); }
If your XML document is stored in a file, you can work with an IOFile instance:
IO input = new IOFile("/path/to/file.xml");
Espero poder ayudarte, Christian
On Thu, May 24, 2018 at 12:50 AM, wd@creativosdigitales.co wrote:
Hi,
I’m writing a Java program to execute an XQuery using the BaseX QueryProcessor class, and need to pass an XML document as context node.
As far I’ve found in the documentation and java examples, this is done with the context() method of QueryProcessor, which receives an instance of the Value class as parameter.
But the examples available are about passing simple types (strings o numbers) but nothing about passing an XML node.
My question is: Where can I find examples or documentation on how to pass XML nodes as parameters to QueryProcessor.context() ?
Thanks for all your help,
William David Velásquez Creativo de Software Creativos Digitales S.A.S. Calle 30A # 83 - 53 Local 1033 Tel: 322 1730 - 311 709 8421 Medellín, Colombia
¿Necesita Integrar Sistemas? Conozca nuestra solución de Integración no Invasiva: http://creativosdigitales.co
¿Preguntas sobre Facturación Electrónica? Visite: http://facturasyrespuestas.com
Hi Christian,
It worked like a charm!
This IO classes opens a new and interesting possibility for using BaseX as an standalone XQuery processor.
Gracias por tu ayuda!
- William
-----Original Message----- From: Christian Grün christian.gruen@gmail.com Sent: jueves, 24 de mayo de 2018 5:25 a.m. To: wd@creativosdigitales.co Cc: BaseX basex-talk@mailman.uni-konstanz.de Subject: Re: [basex-talk] How to pass a document as context to QueryProcessor
Hi William,
Here’s one way to do this:
Context ctx = new Context(); IO input = new IOContent("<xml/>"); DBNode node = new DBNode(input); try(QueryProcessor qp = new QueryProcessor(".", ctx).context(node)) { System.out.println(qp.value()); }
If your XML document is stored in a file, you can work with an IOFile instance:
IO input = new IOFile("/path/to/file.xml");
Espero poder ayudarte, Christian
On Thu, May 24, 2018 at 12:50 AM, wd@creativosdigitales.co wrote:
Hi,
I’m writing a Java program to execute an XQuery using the BaseX QueryProcessor class, and need to pass an XML document as context node.
As far I’ve found in the documentation and java examples, this is done with the context() method of QueryProcessor, which receives an instance of the Value class as parameter.
But the examples available are about passing simple types (strings o numbers) but nothing about passing an XML node.
My question is: Where can I find examples or documentation on how to pass XML nodes as parameters to QueryProcessor.context() ?
Thanks for all your help,
William David Velásquez Creativo de Software Creativos Digitales S.A.S. Calle 30A # 83 - 53 Local 1033 Tel: 322 1730 - 311 709 8421 Medellín, Colombia
¿Necesita Integrar Sistemas? Conozca nuestra solución de Integración no Invasiva: http://creativosdigitales.co
¿Preguntas sobre Facturación Electrónica? Visite: http://facturasyrespuestas.com
basex-talk@mailman.uni-konstanz.de