Missed few details.

I am running the java program from eclipse 4.5.2 IDE in a windows 7 environment 
and my marklogic instance is also on the same host and it is of version 7.0-6.3



From: Yalaverthi, Sudheer (LNG-RDU)
Sent: Friday, June 03, 2016 1:32 PM
To: '[email protected]'
Subject: XDMP-DOCROOTTEXT error

Hi,


I have a simple java program that I am trying to use to insert an xml content 
into MarkLogic database using an xdbc server.

Below is the program

import java.io.ByteArrayInputStream;
import java.io.IOException;

import com.marklogic.xcc.Content;
import com.marklogic.xcc.ContentCreateOptions;
import com.marklogic.xcc.ContentFactory;
import com.marklogic.xcc.ContentSource;
import com.marklogic.xcc.ContentSourceFactory;
import com.marklogic.xcc.Session;
import com.marklogic.xcc.exceptions.RequestException;

public class XccTest {

       public static void main(String[] args) throws RequestException, 
IOException {
              ContentSource contentSource =
                         ContentSourceFactory.newContentSource ("localhost", 
9001, "user", "password");

              ContentCreateOptions options = 
ContentCreateOptions.newXmlInstance();
              options.setCollections(new String[]{"test"});
              options.setFormatXml();
              Session session = contentSource.newSession ("databasename");
              Content content =
                  ContentFactory.newContent ("/sample/javatest.xml", new 
ByteArrayInputStream("<root>hi</root>".getBytes("UTF-8")), options);
              session.insertContent(content);
              System.out.println("done");
       }

}

When I run this, I see the following xdmp-docroottext error

Exception in thread "main" com.marklogic.xcc.exceptions.XQueryException: 
XDMP-DOCROOTTEXT: Invalid root text "015&#10;" at /sample/javatest.xml line 2
       at 
com.marklogic.xcc.impl.handlers.ServerExceptionHandler.handleResponse(ServerExceptionHandler.java:31)
       at 
com.marklogic.xcc.impl.handlers.ContentInsertController.serverDialog(ContentInsertController.java:120)
       at 
com.marklogic.xcc.impl.handlers.AbstractRequestController.runRequest(AbstractRequestController.java:72)
       at com.marklogic.xcc.impl.SessionImpl.insertContent(SessionImpl.java:204)
       at com.marklogic.xcc.impl.SessionImpl.insertContent(SessionImpl.java:235)
       at XccTest.main(XccTest.java:24)

When I change the options format to text,

options.setFormatText();

Then the document gets inserted, but it has some characters being appended to 
the file at the beginning and ending of it like below.

015

<root>hi</root>10


Any thoughts on what is causing this?


Thanks,
Sudheer
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to