Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Unable to use fn: string funtion

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Lovenish Goyal <lovenishgoyal AT gmail.com>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] Unable to use fn: string funtion
  • Date: Tue, 10 Jun 2014 10:41:30 +0000 (UTC)

I am trying to print some string as a xQuery output from java code but
output is generating with some garbage/additional information.

Java Code

Nodes results = XQueryUtil.xquery(doc_from, query);
String outPut = "";
for (int i = 0; i < results.size(); i++) {
outPut += results.get(i).toXML();
}
System.out.println("output: " + conditionIfElseOutput);

XML file

<?xml version="1.0" encoding="UTF-8"?>

<bookstore>

<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>

<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>

<book category="WEB">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>

<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>

</bookstore>

xQuery:

let $document := //bookstore
for $x in $document/book
return
if ($x/price>30)
then
string(123)
else ()

Output:

<item:atomic-value xmlns:item="http://dsd.lbl.gov/nux";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:type="xs:string">123</item:atomic-value><item:atomic-value
xmlns:item="http://dsd.lbl.gov/nux";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:type="xs:string">123</item:atomic-value>


Why is this happening? I am expecting that I should get 123... back.






Archive powered by MHonArc 2.6.24.

Top of Page