Xquery Result

Having trouble installing Oxygen? Got a bug to report? Post it all here.
naveen1308
Posts: 4
Joined: Fri Nov 07, 2008 1:55 am

Xquery Result

Post by naveen1308 »

Hello,
Am new to Oxygen, am trying to run xquery on oxygen10.0, but am getting empty output. Do I need to configure anything before I run xqueries.

Please let me know.

Thanks,
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Xquery Result

Post by sorin_ristache »

Hello,

For running an XQuery in Oxygen you need to configure a transformation scenario. Please give more details about your query. An example of the XQuery file and the XML input file and the name of the transformer set in the scenario will be helpful.


Regards,
Sorin
naveen1308
Posts: 4
Joined: Fri Nov 07, 2008 1:55 am

Re: Xquery Result

Post by naveen1308 »

Actually I have integrated Oxygen 10.0 wityh Marklogic server 4.0. AM trying to run xqueries in marklogic from oxygen using marklogic xquery engine but am getting empty result. I think its a namespace issue, but not sure.

Can someone help me?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Xquery Result

Post by sorin_ristache »

Can you post your XQuery file? What is the XML data on which the query is applied?


Regards,
Sorin
naveen1308
Posts: 4
Joined: Fri Nov 07, 2008 1:55 am

Re: Xquery Result

Post by naveen1308 »

Here is the XML Data and XQuery file am trying to run on marklogic from Oxygen

XML:

<books>
<book bookid="1" pubdate="03/01/2002">
<title>Java Web Services</title>
<authors>
<author>David A. Chappel</author>
<author>Tyler Jewell</author>
</authors>
<subject>Web Services</subject>
</book>
<book bookid="2" pubdate="01/01/2000">
<title>Java Message Service</title>
<authors>
<author>David A. Chappel</author>
</authors>
<subject>Java Message Service (JMS)</subject>
</book>
<book bookid="3" pubdate="03/01/2002">
<title>Professional ebXML Foundations</title>
<authors>
<author>Colleen Evans</author>
<author>David A. Chappel</author>
<author>Jean-Jacques Dubray</author>
<author>Duane Nickull</author>
<author>Pim van der Eijk</author>
<author>Vivek Chopra</author>
<author>Betty Harvey</author>
<author>Marcel Noordzij</author>
<author>Jan Vegt</author>
<author>Tim McGrath</author>
<author>Bruce Peat</author>
</authors>
<subject>ebXML</subject>
</book>
<book bookid="4" pubdate="01/03/1997">
<title>Beginning Visual C++ 6 Database Programming</title>
<authors>
<author>John Connell</author>
<author>Minollo</author>
</authors>
<subject>Database</subject>
</book>
<book bookid="5" pubdate="11/10/2000">
<title>Beginner's Guide to Access 2.0</title>
<authors>
<author>Wrox Author Team</author>
<author>minollo@minollo.com</author>
</authors>
<subject class="1">Access</subject>
</book>
<book bookid="6" pubdate="11/12/1999">
<title>Beginning Java 2</title>
<authors>
<author>Ivor Horton</author>
</authors>
<subject>Java</subject>
</book>
<book bookid="7" pubdate="02/07/1998">
<title>Beginning ATL COM Programming</title>
<authors>
<author>Richard Grimes</author>
<author>George Reilly</author>
<author>Alex Stockton</author>
<author>Julian Templeman</author>
</authors>
<subject>C++</subject>
</book>
<book bookid="8" pubdate="10/01/1999">
<title>XML Applications</title>
<authors>
<author>Frank Boumphrey</author>
<author>Olivia di Renzo</author>
<author>Jon Duckett</author>
<author>Joe Graf</author>
<author>Dave Hollander</author>
<author>Paul Houle</author>
<author>Trevor Jenkins</author>
<author>Peter Jones</author>
<author>Adrian Kingsley-Hughes</author>
<author>Kathie Kingsley-Hughes</author>
<author>Craig McQueen</author>
<author>Stephen Mohr</author>
</authors>
<subject>XML</subject>
</book>
<book bookid="9" pubdate="11/12/1999">
<title>Instant UNIX</title>
<authors>
<author>Andrew Evans</author>
<author>Neil Matthew</author>
<author>Richard Stones</author>
</authors>
<subject>GNU/Linux</subject>
</book>
</books>


XQuery:

<ul>
{
for $x in doc("books.xml")/books/book
return <li>{string($x/title)}</li>
}
</ul>
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Xquery Result

Post by sorin_ristache »

Hello,

Just put the XML file in a collection in the MarkLogic database and use one of the functions doc() or xdmp:directory() to read the file content. For example you right click on the root of the MarkLogic connection in the Database Explorer view of Oxygen (the Database perspective), select the action Add Container in the popup menu and enter the collection name, for example BOOK_TEST. Right-click on the folder node BOOK_TEST in the Database Explorer view, select Add Resource, select the XML file (books.xml). After book.xml is added to BOOK_TEST create an XQuery file for editing in Oxygen:

Code: Select all

<ul> {
for $book in xdmp:directory("/BOOK_TEST/","1")//book
return <li>{$book/title/text()}</li>
} </ul>
Create an XQuery transformation scenario for this XQuery file and set in the scenario as transformation engine a MarkLogic connection configured in Preferences.

You can use also the doc() function in your XQuery for accessing the XML file from the MarkLogic database, for example:

Code: Select all

<ul> {
for $book in doc("/BOOK_TEST/books.xml")//book
return <li>{$book/title/text()}</li>
} </ul>

Regards,
Sorin
naveen1308
Posts: 4
Joined: Fri Nov 07, 2008 1:55 am

Re: Xquery Result

Post by naveen1308 »

Hello,
I have followed the same Steps you have mentioned and I executed
below xquery with Xquery Transformation Engine as Marklogic.

Code: Select all


<ul> {
for $book in doc("/BOOK_TEST/books.xml")//book
return <li>{$book/title/text()}</li>
} </ul>
Still am getting below output :

<ul/>

But if I use Oxygen built-in Xquery engine am getting output.

Am not sure whatz going on.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Xquery Result

Post by sorin_ristache »

Hello,

Did you create a collection called BOOK_TEST in the MarkLogic database using the Add Collection action available on the popup menu of the Database Explorer view of Oxygen? The added collection should be displayed as a node in the tree with the database contents displayed by the Database Explorer view. Did you add the file books.xml to this collection?

After I add the file books.xml to the collection BOOK_TEST that I created in the MarkLogic database the query that I posted returns the following result when I run it with a MarkLogic connection set as transformer engine:

Code: Select all

<ul>
<li>Java Web Services</li>
<li>Java Message Service</li>
<li>Professional ebXML Foundations</li>
<li>Beginning Visual C++ 6 Database Programming</li>
<li>Beginner's Guide to Access 2.0</li>
<li>Beginning Java 2</li>
<li>Beginning ATL COM Programming</li>
<li>XML Applications</li>
<li>Instant UNIX</li>
</ul>
Regards,
Sorin
Post Reply