Project

Profile

Help

Bug #3007

closed

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

Added by Martin Honnen about 8 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Low
Category:
-
Sprint/Milestone:
-
Start date:
2016-10-23
Due date:
% Done:

100%

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

Description

http://home.arcor.de/martin.honnen/xslt/properties4.html tries to pass the document to be transformed as the sourceText property of the options argument to the transform method and home.arcor.de/martin.honnen/xslt/properties3.html tries to use the sourceNode property documented in http://www.saxonica.com/saxon-js/documentation/index.html#!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") {
            platform.initialize(options);
        }

        //print("Transforming...");

        // 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) {
                    callback(options.principalResult);
                }
            })
        } 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.

Please register to edit this issue

Also available in: Atom PDF Tracking page