How to store a XML document using JavaScript API in Tamino

I have installed the XML starter kit and presently i am trying add an XML document into the Tamino database using the Javascript API. The line of code that is giving me problems is:

var dbname=“http://localhost/tamino/Tele/Telephone”;
var ProcessObj;
var QueryResult;
var ProcessResult;
var zip;
var xqlResult;
var x;
var pageSize=12;

var itemSelected=‘d:/TelephData/Munch1.xml’;
ProcessObj = new TaminoClient(dbname,pageSize);
ProcessResult = ProcessObj.process(itemSelected);
if (ProcessResult.errorNo == “0”)
{

ProcessObj.commit();
return();
}
else document.write(result.errorText);


The error that it is showing is:

Error = INOXJE8407 Invalid Node Type undefined


Could anyone help me please??

Expecting a prompt reply,

Thanx and Warm Regards,

Manpreet.

The problem is that API thinks the node you pass process() is not a DOM Node - neither a Document Node or an element Node. In fact it is a string containing a file path.

The following might work server side but not usually in a browser because of the security model

Are you sing ASP? or is this IE5 code?

var itemSelected=new ActiveXObject(“Microsoft.XMLDOM”);
itemSelected.async=false;
itemSelected.load(‘file:///d:/TelephData/Munch1.xml’);

you used something likehttp://somehost/TelephData/Munch1.xml’
It would work on the client side as well.

I’ve often though of allowing a string as a parameter to .process() and doing this internally
The API would hope that it was a URL and try and use it for loading. The error reporting is a wee bit tricky

Would this be a good idea?

Try this and get back here if my sugestion won’t won’t work.

regards

Nigel Hutchison

Sorry- I gave the code correction without a context

here it is again

var dbname=“http://localhost/tamino/Tele/Telephone”;
var ProcessObj;
var QueryResult;
var ProcessResult;
var zip;
var xqlResult;
var x;
var pageSize=12;

var itemSelected=new ActiveXObject(“Microsoft.XMLDOM”);
itemSelected.async=false;
itemSelected.load(‘file:///d:/TelephData/Munch1.xml’);


ProcessObj = new TaminoClient(dbname,pageSize);
ProcessResult = ProcessObj.process(itemSelected);
if (ProcessResult.errorNo == “0”)
{

ProcessObj.commit();
return();
}
else document.write(result.errorText);

There is an even easier way of doing this which doesn’t involve explicitly instantiating
an XMLDOM ActiveXObject. The proviso is that you have the absolute URL of the document.

ProcessObj = new TaminoClient(dbname,pageSize);
GetResult=ProcessObj.getDocument(‘file:///d:/TelephData/Munch1.xml’);
//error check here.
ProcessResult = ProcessObj.process(GetResult.DOM)

this has the advantages that it is
1) Simpler - you don’t have to remember how to force synchronism and which XMLDOM variant to use.
2) Has the same error handling - if you want to error check on the XMLDOM load method you have to remember how that works.

Note that getDocument does have to operate on Tamino - It works with any HTTP or file:/// source - security model permitting.