This discussion is archived
1 Reply Latest reply: Mar 2, 2011 1:10 PM by 637288 RSS

Returning an XmlDocument from an external function?

835648 Newbie
Currently Being Moderated
Hi,

In an attempt to simplify my XQueries, I have started looking at writing some of the more complex functions in Java and calling them via an XmlExternalFunction.

This seems fine, except that I have an issue with returning a constructed document (or any node set). The only way I have found to return a document without it being destroyed is to put it into a temporary database first. Here is the end of my function. I have written a convenience function that converts a DOM Xml Document into a dbxml XmlDocument (DomToXmlDbDoc).

     XmlResults results = mgr.createResults();
     XmlDocument result = DomToXmlDbDoc(doc);
     XmlContainer tmp = mgr.openContainer(txn, "_tmp.dbxml");
     result.setName(UUID.randomUUID().toString());
     putDocument(tmp, result);
     tmp.close();
     XmlValue value = new XmlValue(result);
     results.add(value);
     return results;

I would prefer not to have to use the temporary storage in the middle as it is inefficient and rather untidy, but the following just gives a blank result.

     XmlResults results = mgr.createResults();
     XmlDocument result = DomToXmlDbDoc(doc);
     XmlValue value = new XmlValue(result);
     results.add(value);
     return results;

Best Regards
Pete.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points