Bug #3007


sourceNode or sourceText property of options argument of transform method not used

Added by Martin Honnen over 7 years ago. Updated almost 7 years ago.

Start date:
Due date:
% Done:


Estimated time:
Applies to JS Branch:
Fix Committed on JS Branch:
Fixed in JS Release:
SEF Generated with:
Contact person:
Additional contact persons:

Description tries to pass the document to be transformed as the sourceText property of the options argument to the transform method and tries to use the sourceNode property documented in!api/transform but both pages fail with "Uncaught No source document, initial template, or initial mode supplied" as it seems neither sourceNode nor sourceText is supported inside of the browser, the code in transform has

    function transform(options, callback) {

        if (typeof platform.initialize === "function") {


        // Options is an object (map) that can include:
        // stylesheetNode - the stylesheet as a document node
        // stylesheetText - the stylesheet as lexical XML
        // stylesheetLocation - the URI of the stylesheet
        // stylesheetFileName - the file name of the stylesheet
        // stylesheetParams - object containing values of global stylesheet parameters

        // sourceNode - the source document as a document node
        // sourceText - the source document as lexical XML
        // sourceLocation - the URI of the source document
        // sourceFileName - the file name of the source document

        // initialTemplate - the initial template name as an EQName
        // initialMode - the initial mode name as an EQName

        // detination - determines what happens to the principal result tree from the transformation
        //    possible values: "replaceBody" | "appendToBody" | "prependToBody" | "application"

        if (!options.stylesheetParams) {
            options.stylesheetParams = {};

        var stylesheet, sourceDoc;

        if (inBrowser) {
            if (options.stylesheetLocation === undefined) {
                throw "No stylesheet supplied";
            platform.asyncGetMultipleXml([options.stylesheetLocation, options.sourceLocation], function (docs) {
                stylesheet = docs[options.stylesheetLocation] /*|| options.stylesheetNode*/;
                sourceDoc = docs[options.sourceLocation] /*|| options.sourceNode*/;
                applyStylesheet(stylesheet, sourceDoc, options);
                if (callback) {
        } else {
            stylesheet = options.stylesheetNode;
            if (!stylesheet) {
                var stylesheetText = options.stylesheetText;
                if (!stylesheetText) {
                    var stylesheetFileName = options.stylesheetFileName;
                    if (!stylesheetFileName) {
                        throw "No stylesheet supplied";
                    stylesheetText = platform.readFile(stylesheetFileName);
                stylesheet = platform.parseXmlFromString(stylesheetText);
            sourceDoc = options.sourceNode;
            if (!sourceDoc) {
                var sourceText = options.sourceText;
                if (!sourceText) {
                    var sourceFileName = options.sourceFileName;
                    if (sourceFileName) {
                        sourceText = platform.readFile(sourceFileName);
                if (sourceText) {
                    sourceDoc = platform.parseXmlFromString(sourceText);
            applyStylesheet(stylesheet, sourceDoc, options);


so sourceDoc = docs[options.sourceLocation] /*|| options.sourceNode*/ comments out the use of sourceCode in the inbrowser branch and sourceText only seems to be supported outside of inbrowser@. As @sourceCode is documented for Saxon-JS, I guess it should work.

Actions #1

Updated by Debbie Lockett over 7 years ago

  • Assignee set to Debbie Lockett
  • Found in version set to 0.9

Thanks for raising the bug. We were aware that only the sourceLocation transform property would work in the browser for the first Saxon-JS beta release, so it is a mistake that sourceNode made it into the documentation already.

We do need to get sourceNode working; this is a bug.

I'm not sure if we will also implement sourceText for use in the browser, or if this is just intended to be used in other environments.

Actions #2

Updated by Debbie Lockett over 7 years ago

Note added to the documentation for sourceNode at!api/transform, to say this does not work yet!

Actions #3

Updated by Debbie Lockett over 7 years ago

  • Status changed from New to Resolved

Use of the transform options sourceNode and sourceText is now implemented. So these will be available for use with the next Saxon-JS release.

The documentation will need to be updated.

Actions #4

Updated by Debbie Lockett over 7 years ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 0.9.1

Bug fix applied in the Saxon-JS 0.9.1 beta release.

Actions #5

Updated by Community Admin almost 7 years ago

  • % Done changed from 0 to 100
  • Fixed in JS Release set to Saxon-JS 0.9.1
  • Applies to JS Branch 0.9 added
  • Fix Committed on JS Branch 0.9 added

Please register to edit this issue

Also available in: Atom PDF Tracking page