Dear Anand,
Thanks for the reply. The serialize() did work. But what I was expecting Is pure textual output and I am getting XML output. The output which I am getting is -
I strongly recommend you to spend some more time to get into XPath and XQuery, as those issues can all be realized fairly easily with the languages themselves. Some straightforward tutorials are e.g. found at [1,2].
Here are some examples (among many others) how you could rewrite your query to get the desired results:
for $x in doc('input.xml')//li return $x/text() doc('input.xml')//li/text() doc('input.xml')//li/string() doc('input.xml')//li/data()
You can also compose the whole combobox within XQuery. Your query could then look like…
<select>{ for $x in doc('input.xml')//li return <option>{ $x/text() }</option> }</select>
…or…
element select { doc('input.xml')//li ! element option { text() } }
Hope this helps, Christian
[1] http://www.w3schools.com/xpath [2] http://www.w3schools.com/xquery
- Convert each result to its Java representation:
Iterator
<li>Exercise 1</li> <li>Exercise 2</li> -----------------------------------------------------------
But I am expecting this is -
Exercise 1 Exercise 2
Actually I want to populate a JComboBox which is a part of my front-end. So I thought that this piece of code, where it is said "Java representation", would gimme the output as I required.
Can you help me a little more..? Which method will gimme the plain output, without the XML Tags...? So that I can populate a JComboBox... !!
Regards, Anand Chiney
-----Original Message----- From: Christian Grün [mailto:christian.gruen@gmail.com] Sent: Saturday, July 07, 2012 5:02 PM To: Anand Chiney (AIR); BaseX Subject: Re: Problem with RunQueries.java example!!
Here's a second feedback (sorry for being distracted): Your query does return standard Java DOM elements, the toString() method of which returns "[li: null]". As you are probably interested in the string representation of the elements, you'll need to replace "toJava()" with "serialize()":
System.out.println(item.serialize());
Hope this helps, Christian ___________________________
On Sat, Jul 7, 2012 at 1:26 PM, Christian Grün christian.gruen@gmail.com wrote:
Your query will yield the expected results if you remove the explicit cq.execute(); call.
In the latest snapshot [1], an exception will be returned if the result has already been requested.
Hope this helps, Christian
[1] http://files.basex.org/releases/latest/ ___________________________
Dear Christian
Please find attached 2 files, MyRunQueries.java and input.xml
The .java file is an edited version of RunQueries.java version and the
I hope this would be sufficient for you to test.
Regards Anand chiney
-----Original Message----- From: Christian Grün [mailto:christian.gruen@gmail.com] Sent: Saturday, July 07, 2012 4:34 PM To: Sandeep Yohans Cc: Anand Chiney; basex-talk@mailman.uni-konstanz.de Subject: Re: Problem with RunQueries.java example!!
One again I'm sorry… Please send us a (small !) example that we can try by ourselves.
Thank you in advance, Christian ___________________________
On Sat, Jul 7, 2012 at 1:02 PM, Sandeep Yohans sandeepy.air@gmail.com wrote:
Hello Christian,
We are extracting names from a very long list of names. The
item.toJava()
method call in iterate(query) is returning null. example output:
[li: null]
Rest of the methods are printing output fine.
-- Thanks and Regards
Sandeep Yohans Software Developer Systems - AIR Infotech Nagpur - India www.airinfotech.in Mobile: +91-997-086-5520