hi folks,

I have recently started using Xindice and i am facing a peculiar problem
while inserting an XML document into the database. I am using the XML-RPC
API to accomplish this (though i dont think it matters in the problem
context).

The problem is that my program cannot reliably insert valid XML documents
into the database. (Although the command-line tool does it successfully). 

Below are the errors i get..

Xindice server gives the following error:

Fatal error parsing XML: org.xml.sax.SAXParseException: Document contains
illegal control character with value 0

and my program gets the following error thru XML-RPC:

XML-RPC Fault: java.lang.StringIndexOutOfBoundsException: String index out
of range: -1 (0)

One more thing, i am passing the XML document as a null-terminated
character string from my C program...and the document is valid.

But sometimes the document does get inserted successfully whereas most of
the time the operation fails. This makes it harder to figure out.

I am completely stuck at this point...Any help in this regard would be
appreciated....

PS: I have attached the routine which does most of the stuff below. My
program just reads an XML file and passes the data to this routine. 

TIA,
imran



int db_create_document(char *colname, char *doc_id, char *doc) {
        xmlrpc_env env;
        xmlrpc_value *result;
        char *id;

        xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, NAME, VERSION);
        xmlrpc_env_init(&env);

        result = xmlrpc_client_call(&env, SERVER_URL, "db.insertDocument",
                        "(sss)", colname, doc_id, doc);
        if(db_if_fault_occurred(&env))
                return 0;
        
        xmlrpc_parse_value(&env, result, "s", &id);
        if(db_if_fault_occurred(&env))
                return 0;
        
        printf("ID: %s\n", id);
        
        xmlrpc_DECREF(result);
        xmlrpc_env_clean(&env);
        xmlrpc_client_cleanup();
        return 1;
}


Reply via email to