rimmartin / saxon-node

MIT License
64 stars 6 forks source link

Resolve file paths and content #2

Open seanmcilvenna opened 9 years ago

seanmcilvenna commented 9 years ago

When a file processed with saxon is compiled/executed, it may require other files. For example, in XSLT, you can use the document() function to return the contents of another XML document, ex:

XSLT's can also be modularized, like so:

When saxon processes schemas, it may have include/import schemas, ex:

If I am trying to process these types of XSLTs and schemas in-memory, is there a way to intercept file i/o requests from saxon and respond with the expected content? Example:

saxon.fileResolver = function(fileName) {
    switch (fileName) {
        case "utility.xslt":
             return new Buffer("<xsl:stylesheet>...</xsl:stylesheet>");
        case "module.xsd":
             return new Buffer("<xsd:schema>...</xsd:schema>");
        default: throw "File not found/loaded";
    }
};
ond1 commented 9 years ago

You should be able to load a string representation of the XSLT in Saxon/C using the compile method.

Schema processing is not currently supported but will be included in the next release.

On 4 Aug 2015, at 06:20, Sean McIlvenna <notifications@github.com mailto:notifications@github.com> wrote:

When a file processed with saxon is compiled/executed, it may require other files. For example, in XSLT, you can use the document() function to return the contents of another XML document, ex: XSLT's can also be modularized, like so: When saxon processes schemas, it may have include/import schemas, ex:

If I am trying to process these types of XSLTs and schemas in-memory, is there a way to intercept file i/o requests from saxon and respond with the expected content? Example:

saxon.fileResolver = function(fileName) { switch (fileName) { case "utility.xslt": return new Buffer("xsl:stylesheet.../xsl:stylesheet"); case "module.xsd": return new Buffer("xsd:schema.../xsd:schema"); default: throw "File not found/loaded"; } };

— Reply to this email directly or view it on GitHub https://github.com/rimmartin/saxon-node/issues/2.

rimmartin commented 9 years ago

saxon-node needs the compileString glue implemented. Adding it...

rimmartin commented 9 years ago

if a compileBuffer can be made more efficient [ by avoiding copying] I'll add one for it too