nori
nori

Reputation: 1

<notes domino Xpages> lotus script to ssjs

I wish to change this code from Lotus Script to SSJS.

Query = "test"
Maxdocs = 10
Sortoption = 32
Otheroptions = 8192
Start = 1
Count = 30
Entryform = "ResultEntry"
Set RetDoc = curDB.Ftdomainsearch(Query, Maxdocs, Sortoption,Otheroptions,Start,Count,Entryform)

'domino Xml
Set ndxl = ss.CreateDXLExporter(Retdoc)
Set stream = ss.CreateStream
Call ndxl.SetOutput(stream)
ret = ndxl.Export(Retdoc)
Set domParser=ss.CreateDOMParser(ret, stream)
domParser.Process

'doclink
Set rootElement = domParser.Document.DocumentElement

Set docList = rootElement.GetElementsByTagName ("doclink")

================================

I created this ssjs code by myself.but an error occurred.

var Query = "a";
var Maxdocs = 10;
var Sortoption = 32;
var Otheroptions = 8192;
var Start = 1;
var Count = 30;
var Entryform = "ResultEntry";
var RetDoc:NotesDocument = database.FTDomainSearch(Query, Maxdocs, Sortoption,Otheroptions,Start,Count,Entryform);

var stream:NotesStream = session.createStream();
var ndxl:NotesDxlExporter = session.createDxlExporter();

var ret:string = ndxl.exportDxl(RetDoc);
var parser = new DOMParser();
var doc = parser.parseFromString(ret, "application/xml");

var rootElement = doc.DocumentElement;
var docList = rootElement.GetElementsByTagName ("doclink");

==================================

The error is described below.

" DOMParseris not found" A sentence of error var parser = new DOMParser();

Please tell me the correct code in ssjs.

Upvotes: 0

Views: 206

Answers (1)

Lothar Mueller
Lothar Mueller

Reputation: 2528

I'm not sure what kind of object DOMParser is supposed to be; two options:

a) you wish to us a java class, maybe Oracle's version, or the one from Apache's Xerces-J API. In both (or other cases) you could try to call the class constructor by passing the full package name as in var parser=new oracle.xml.parser.v2.DOMParser; be aware that this is just an example; both DOMParser classes don't have parseFromString() methods.

b) more probably you're trying to use a client side javascript DOMParser object; to my knowledge this object is not available in Domino's SSJS implementation, at least I can't find any trace of it.

The bottom line: you'll have to look for a different way, most probably using appropriate java classes; may Paul Calhoun's example (linked in Frank van der Linden's comment) can be of help.

Upvotes: 1

Related Questions