How to get list as result instead of a String

Thursday, 4 April 2013 · 5 messages · last reply 12 Apr 2013
EM
elangovan MuthuSwamy4 Apr 2013 11:47 #
Hi All, I am using XQuery to evaluate an xpath. My code is as follows,
/*Example xml I am using
<interface>
  <name>intf0</name>
</interface>
<interface>
  <name>intf1</name>
</interface>
<interface>
  <name>intf2</name>
</interface>
<interface>
  <name>intf3</name>
</interface>
*/
XQuery query = new XQuery("/interfaces/interface/name/text()");
String str = query.execute(ctx);
// Result string is - intf0intf1intf2intf3 I want the result such as intf0 intf1 intf2 intf3 I could not get the result list and I could not differentiate whether the result has multiple values or a single value. Please advice me if there is any other way to identify the result list. Thanks in Advance.
-- Regards, Elango.
AH
Alexander Holupirek5 Apr 2013 09:13 #
Hi Elango, changing the serialization parameters, here: output:separator option, [1] could do the trick.
declare option output:separator "\n";

let $s :=
  <interfaces>
    <interface>
      <name>intf0</name>
    </interface>
    <interface>
      <name>intf1</name>
    </interface>
    <interface>
      <name>intf2</name>
    </interface>
    <interface>
      <name>intf3</name>
    </interface>
  </interfaces>
return
  $s/interface/name/text()
==> intf0 intf1 intf2 intf3 Hope this helps, Alex [1] http://docs.basex.org/wiki/Serialization
Quoted text · elangovan MuthuSwamy · 43 lines
On 04.04.2013, at 11:47, elangovan MuthuSwamy <elangovan.h at gmail.com> wrote: > Hi All, > > I am using XQuery to evaluate an xpath. My code is as follows, > > /*Example xml I am using > <interface> > <name>intf0</name> > </interface> > <interface> > <name>intf1</name> > </interface> > <interface> > <name>intf2</name> > </interface> > <interface> > <name>intf3</name> > </interface> > */ > XQuery query = new XQuery("/interfaces/interface/name/text()"); > String str = query.execute(ctx); > > // Result string is - intf0intf1intf2intf3 > > I want the result such as > intf0 > intf1 > intf2 > intf3 > > I could not get the result list and I could not differentiate whether the result has multiple values or a single value. > > Please advice me if there is any other way to identify the result list. > > Thanks in Advance. > > -- > Regards, > Elango. > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
AH
Alexander Holupirek11 Apr 2013 12:13 #
Hi Elango, you may have a look at [1], this might help you setting options? HTH, Alex [1] http://docs.basex.org/wiki/Options
Quoted text · elangovan MuthuSwamy · 92 lines
On 08.04.2013, at 09:07, elangovan MuthuSwamy <elangovan.h at gmail.com> wrote: > Thanks Alex, > > Where can I change the serialization parameters? > > I have set SERIALIZER property in .basex file, but I got the following error in server log. > > /.basex: "SERIALIZER" not found. > > Am I missing anything basically? > > Regards, > Elango. > > > On Fri, Apr 5, 2013 at 12:43 PM, Alexander Holupirek <alexander.holupirek at uni-konstanz.de> wrote: > Hi Elango, > > changing the serialization parameters, here: output:separator option, [1] could do the trick. > > declare option output:separator "\n"; > > let $s := > <interfaces> > <interface> > <name>intf0</name> > </interface> > <interface> > <name>intf1</name> > </interface> > <interface> > <name>intf2</name> > </interface> > <interface> > <name>intf3</name> > </interface> > </interfaces> > return > $s/interface/name/text() > > ==> > > intf0 > intf1 > intf2 > intf3 > > Hope this helps, > Alex > > [1] http://docs.basex.org/wiki/Serialization > > On 04.04.2013, at 11:47, elangovan MuthuSwamy <elangovan.h at gmail.com> wrote: > >> Hi All, >> >> I am using XQuery to evaluate an xpath. My code is as follows, >> >> /*Example xml I am using >> <interface> >> <name>intf0</name> >> </interface> >> <interface> >> <name>intf1</name> >> </interface> >> <interface> >> <name>intf2</name> >> </interface> >> <interface> >> <name>intf3</name> >> </interface> >> */ >> XQuery query = new XQuery("/interfaces/interface/name/text()"); >> String str = query.execute(ctx); >> >> // Result string is - intf0intf1intf2intf3 >> >> I want the result such as >> intf0 >> intf1 >> intf2 >> intf3 >> >> I could not get the result list and I could not differentiate whether the result has multiple values or a single value. >> >> Please advice me if there is any other way to identify the result list. >> >> Thanks in Advance. >> >> -- >> Regards, >> Elango.
EM
elangovan MuthuSwamy12 Apr 2013 06:59 #
Thanks Alex, I have set config options in .base file as follows, # Local Options SERIALIZER separator=\n Also I have tried different options like # Local Options separator=\n # Local Options item-separator=\n It doesn't change anything in the output. I got the same concatenated results as I got earlier. I am very beginner to use BaseX. Please help me to fix this problem, Many Thanks, Elango.
Quoted text · Alexander Holupirek · 115 lines
On Thu, Apr 11, 2013 at 3:43 PM, Alexander Holupirek < alexander.holupirek at uni-konstanz.de> wrote: > Hi Elango, > > you may have a look at [1], this might help you setting options? > > HTH, > Alex > > [1] http://docs.basex.org/wiki/Options > > On 08.04.2013, at 09:07, elangovan MuthuSwamy <elangovan.h at gmail.com> > wrote: > > > Thanks Alex, > > > > Where can I change the serialization parameters? > > > > I have set SERIALIZER property in .basex file, but I got the following > error in server log. > > > > /.basex: "SERIALIZER" not found. > > > > Am I missing anything basically? > > > > Regards, > > Elango. > > > > > > On Fri, Apr 5, 2013 at 12:43 PM, Alexander Holupirek < > alexander.holupirek at uni-konstanz.de> wrote: > > Hi Elango, > > > > changing the serialization parameters, here: output:separator option, > [1] could do the trick. > > > > declare option output:separator "\n"; > > > > let $s := > > <interfaces> > > <interface> > > <name>intf0</name> > > </interface> > > <interface> > > <name>intf1</name> > > </interface> > > <interface> > > <name>intf2</name> > > </interface> > > <interface> > > <name>intf3</name> > > </interface> > > </interfaces> > > return > > $s/interface/name/text() > > > > ==> > > > > intf0 > > intf1 > > intf2 > > intf3 > > > > Hope this helps, > > Alex > > > > [1] http://docs.basex.org/wiki/Serialization > > > > On 04.04.2013, at 11:47, elangovan MuthuSwamy <elangovan.h at gmail.com> > wrote: > > > >> Hi All, > >> > >> I am using XQuery to evaluate an xpath. My code is as follows, > >> > >> /*Example xml I am using > >> <interface> > >> <name>intf0</name> > >> </interface> > >> <interface> > >> <name>intf1</name> > >> </interface> > >> <interface> > >> <name>intf2</name> > >> </interface> > >> <interface> > >> <name>intf3</name> > >> </interface> > >> */ > >> XQuery query = new XQuery("/interfaces/interface/name/text()"); > >> String str = query.execute(ctx); > >> > >> // Result string is - intf0intf1intf2intf3 > >> > >> I want the result such as > >> intf0 > >> intf1 > >> intf2 > >> intf3 > >> > >> I could not get the result list and I could not differentiate whether > the result has multiple values or a single value. > >> > >> Please advice me if there is any other way to identify the result list. > >> > >> Thanks in Advance. > >> > >> -- > >> Regards, > >> Elango. > > > > >
-- Regards, Elango.
DK
Dirk Kirsten12 Apr 2013 09:19 #
Hello Elango, You have to use item-seperator, see http://docs.basex.org/wiki/Serialization. So for .basex include a line like this: SERIALIZER = item-seperator=\n Cheers, Dirk
Quoted text · elangovan MuthuSwamy · 154 lines
On Fri, Apr 12, 2013 at 6:59 AM, elangovan MuthuSwamy <elangovan.h at gmail.com > wrote: > Thanks Alex, > > I have set config options in .base file as follows, > > # Local Options > SERIALIZER separator=\n > > Also I have tried different options like > > # Local Options > separator=\n > > # Local Options > item-separator=\n > > It doesn't change anything in the output. I got the same concatenated > results as I got earlier. > > I am very beginner to use BaseX. Please help me to fix this problem, > > Many Thanks, > Elango. > > > On Thu, Apr 11, 2013 at 3:43 PM, Alexander Holupirek < > alexander.holupirek at uni-konstanz.de> wrote: > >> Hi Elango, >> >> you may have a look at [1], this might help you setting options? >> >> HTH, >> Alex >> >> [1] http://docs.basex.org/wiki/Options >> >> On 08.04.2013, at 09:07, elangovan MuthuSwamy <elangovan.h at gmail.com> >> wrote: >> >> > Thanks Alex, >> > >> > Where can I change the serialization parameters? >> > >> > I have set SERIALIZER property in .basex file, but I got the following >> error in server log. >> > >> > /.basex: "SERIALIZER" not found. >> > >> > Am I missing anything basically? >> > >> > Regards, >> > Elango. >> > >> > >> > On Fri, Apr 5, 2013 at 12:43 PM, Alexander Holupirek < >> alexander.holupirek at uni-konstanz.de> wrote: >> > Hi Elango, >> > >> > changing the serialization parameters, here: output:separator option, >> [1] could do the trick. >> > >> > declare option output:separator "\n"; >> > >> > let $s := >> > <interfaces> >> > <interface> >> > <name>intf0</name> >> > </interface> >> > <interface> >> > <name>intf1</name> >> > </interface> >> > <interface> >> > <name>intf2</name> >> > </interface> >> > <interface> >> > <name>intf3</name> >> > </interface> >> > </interfaces> >> > return >> > $s/interface/name/text() >> > >> > ==> >> > >> > intf0 >> > intf1 >> > intf2 >> > intf3 >> > >> > Hope this helps, >> > Alex >> > >> > [1] http://docs.basex.org/wiki/Serialization >> > >> > On 04.04.2013, at 11:47, elangovan MuthuSwamy <elangovan.h at gmail.com> >> wrote: >> > >> >> Hi All, >> >> >> >> I am using XQuery to evaluate an xpath. My code is as follows, >> >> >> >> /*Example xml I am using >> >> <interface> >> >> <name>intf0</name> >> >> </interface> >> >> <interface> >> >> <name>intf1</name> >> >> </interface> >> >> <interface> >> >> <name>intf2</name> >> >> </interface> >> >> <interface> >> >> <name>intf3</name> >> >> </interface> >> >> */ >> >> XQuery query = new XQuery("/interfaces/interface/name/text()"); >> >> String str = query.execute(ctx); >> >> >> >> // Result string is - intf0intf1intf2intf3 >> >> >> >> I want the result such as >> >> intf0 >> >> intf1 >> >> intf2 >> >> intf3 >> >> >> >> I could not get the result list and I could not differentiate whether >> the result has multiple values or a single value. >> >> >> >> Please advice me if there is any other way to identify the result list. >> >> >> >> Thanks in Advance. >> >> >> >> -- >> >> Regards, >> >> Elango. >> >> >> >> >> > > > -- > Regards, > Elango. > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >
-- Dirk Kirsten, BaseX GmbH, http://basex.org |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22

⚡Generated with XQuery