I'm passing a nodeset to an ECMAScript from designer policy and want to do some post processing on it under certian circumstances.

Essentially in plain english, I want to pass either a full XDS document or just a command to ECMAScript and have the ECMAScript detect and fix if the command needs to be wrapped in a nds & input nodes.

The end result will always be a full XDS document.

Action: do-set-local-variable("myXDS",notrace="true",scope="policy",arg-node-set(token-xml-parse("<trigger class-name="User" event-id="trigger-job:myTrigger#20160103162607#0#0" qualified-src-dn="O=data\OU=users" source="myTrigger" src-dn="\IDV\data\users" src-entry-id="32881"/>"))).

Action: do-trace-message(token-xml-serialize(notrace="true",token-local-variable("myXDS",notrace="true"))).
arg-string(token-xml-serialize(notrace="true",token-local-variable("myXDS",notrace="true")))
token-xml-serialize(notrace="true",token-local-variable("myXDS",notrace="true"))
-- trace suppressed --
Arg Value: "<trigger class-name="User" event-id="trigger-job:myTrigger#20160103162607#0#0" qualified-src-dn="O=data\OU=users" source="myTrigger" src-dn="\IDV\data\users" src-entry-id="32881"/>".
<trigger class-name="User" event-id="trigger-job:myTrigger#20160103162607#0#0" qualified-src-dn="O=data\OU=users" source="myTrigger" src-dn="\IDV\data\users" src-entry-id="32881"/>

then call an ecmascript function with this nodeset as a param.

Within the ECMAScript I call:

myXDS.getClass()

and get a class of com.novell.xml.xpath.InsertionOrderNodeSet

I want to do something along the lines of the following:


// start ES snippet
importClass(Packages.com.novell.nds.dirxml.engine. NdsDtd);
importClass(Packages.com.novell.nds.dirxml.engine. XdsUtil);
importClass(Packages.com.novell.nds.dirxml.driver. XmlDocument);


function XDSfix(myXDS) {

if (!(myXDS.getNodeName().equals("nds"))) {

//fix doc

var myRootElement = NdsDtd.createDoc("input")
XdsUtil.graftSubtree(myRootElement, myXDS.getFirstChild());
myXDS = myRootElement.getOwnerDocument().getDocumentElemen t()

}

return myXDS

// end ES snippet

The problem is that myXDS.getNodeName() always returns the root "document" node and I can't access the getFirstChild() method.
The code example I am working from is Java and has cast myXDS as an Element rather than an InsertionOrderNodeSet.
I've tried to enforce that casting, without success.

Anyone dug into this type of operation before? All the examples regarding a nodeset seem to indicate one can iterate over the nodeset, but I get nothing useful from that.


And yes, I know I can do this in a few lines of DirXML-Script but I have a whole heap of other logic I need to call from ECMAScript so it makes sense from a design perspective to do it all in ECMAScript.