Assuming your XML document is something like:
<book>
<chapter>..</chapter>
<chapter>..</chapter>
<chapter>..</chapter>
.
</book>
the XQuery for retrieving the 1st chapter would be
doc("<uri of your xml>")/book/chapter[1]
or if you have unique attributes (for example an id) for your chapters:
<book>
<chapter id="."' >..</chapter>
<chapter>..</chapter>
<chapter>..</chapter>
.
</book>
the XQuery for retrieving the 1st chapter could be
doc("<uri of your xml>")/book/[EMAIL PROTECTED]"."]
In general, you can assume that XQuery is a superset of Xpath , so almost
any XPath selector would work.
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Azam
Sent: Monday, November 24, 2008 7:02 PM
To: 'General Mark Logic Developer Discussion'
Subject: RE: [MarkLogic Dev General] XQuery and Mark Logic Sever
Thanks a lot.
I will work out on this as I need c#.net code
But one problem as iam new to xquery can you send me the xquery samples
For pulling the xml document named test.xml at a particular node called
"chapter" from Mark logic server
It will be very helpful for me.
Thanks,
Azam
_____
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Deshbir
Sent: Monday, November 24, 2008 6:57 PM
To: 'General Mark Logic Developer Discussion'
Subject: RE: [MarkLogic Dev General] XQuery and Mark Logic Sever
Hi Azam,
Sample code:
========================================
import com.marklogic.xcc.*;
import java.net.*;
//Setup a connection to Mark Logic XDBC server
URI serverUri = new URI ("xcc://" +
userName + ":" +
pass + "@" +
serverIP + ":" +
port);
ContentSource cs = ContentSourceFactory.newContentSource(serverUri);
Session session = cs.newSession();
//Execute XQuery
String strQuery="<Any XQuery>";
Request request = m_objConnectionSession.newAdhocQuery (strQuery);
ResultSequence rs= session.submitRequest(request);
//Retrieve Output of XQuery
String xmlOutput;
if (rs.hasNext())
{
ResultItem item = rs.next();
xmlOutput = item.asInputStream();
}
//Print XML
System.out.println(xmlOutput);
=====================================
Regards.
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Azam
Sent: Monday, November 24, 2008 6:29 PM
To: [email protected]
Subject: [MarkLogic Dev General] XQuery and Mark Logic Sever
Hi,
I have loaded the Xml document in Mark Logic server using the XCC demo
application.
The main task I need to complete is ,
I have to pull the content from the Xml document which I have loaded into
Mark Login server at a particular node using XQUERY and XCC.
As iam very new to XQUERY.
Could you please send me the process or the sample code for the above task.
Its very urgent.
I will be very helpful to you if I through with my task.
Thanks in Advance.
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general