One obvious issue in the code are the 2 different XBDC ports i.e. 8003 for loading and 8001 pulling content. So you could be loading your XML into a different database and then trying pull it from another one? Also you have "spaces" in your XQuery; not sure, but these could also be a problem. Try without spaces - "xcc://azam:[EMAIL PROTECTED]:8001/GunDigest/DocBookforAuthentic.xml")/boo k/chapter[1]"
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Azam Sent: Monday, November 24, 2008 7:45 PM To: 'General Mark Logic Developer Discussion' Subject: RE: [MarkLogic Dev General] XQuery and Mark Logic Sever C#.net console Application For loading the xml document in Mark Logic server: Uri serverUri = new Uri("xcc://azam:[EMAIL PROTECTED]:8003/GunDigest"); FileInfo[] files = new FileInfo[1]; ContentLoader loader = new ContentLoader(serverUri); files[0] = new FileInfo(@"c:\DocBookforAuthentic.xml"); loader.Load(files); For pulling the content from xml file in Mark Logic server: ContentSource contentSource = ContentSourceFactory.NewContentSource(serverUri);//.newContentSource(serverU ri); Session session = contentSource.NewSession(); string strq = doc("xcc://azam:[EMAIL PROTECTED]:8001/GunDigest/DocBookforAuthentic.xml") / book / chapter[1]; Request request = session.NewAdhocQuery(strq); ResultSequence rs = session.SubmitRequest(request); ConsoleWriteLine(rs.AsString()); ConsoleRead(); For loading the xml document in Mark Logic server code is working But in For pulling the content from xml file in Mark Logic server Near doc and book and chapter iam getting the error as Doc does not exist in the current context book does not exist in the current context Chapter does not exist in the current context Could you please tell me why its happening like this I will be very thankful to you sir. Azam _____ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Deshbir Sent: Monday, November 24, 2008 7:25 PM To: 'General Mark Logic Developer Discussion' Subject: RE: [MarkLogic Dev General] XQuery and Mark Logic Sever 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
