I migrate from saxon-CE to saxonJS (v1.2.0)
The output of the XSLT transformation need to be captured as an XML Document object as it was in saxon-CE:
var xslPath = './*.xsl';
var xsl = Saxon.requestXML(xslPath);
var proc = Saxon.newXSLT20Processor(xsl);
var xmlDoc;
var xmlDocTransformed;
var xmlStr;
xmlDoc = Saxon.parseXML(app.getLoadedMEI());
xmlDocTransformed = proc.transformToDocument(xmlDoc);
It tried to apply SaxonJS this way:
var result;
result = SaxonJS.transform({
stylesheetLocation: "./*.sef.xml",
sourceLocation: "./*.xml",
destination: "application"
});
and expected to get a transformation results object where I can access the principalResult property as described in the official documentation (#destination) and in this presentation.
When running the code I obtain the following:
There is no problem with transformation itself: when destination is set to replaceBody it works as expected.


One way is, of course, to use the
fn:transformfunction with "normal" XSLT code:Not recommended for performance reason but perhaps a workaround that avoid the hassle of creating an SEF. If you want to create an SEF, note, that the Node.js
xslt3tool from Saxonica can also do that, you don't need a current version of Saxon EE, justxslt3 -t -export:my-sheet.sef.json -nogo -xsl:my-sheet.xsl.