saxon-node icon indicating copy to clipboard operation
saxon-node copied to clipboard

Resolve file paths and content

Open seanmcilvenna opened this issue 10 years ago • 3 comments

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: <xsl:value-of select="document('myDocument.xml')/root/someElement/@someAttr" />

XSLT's can also be modularized, like so: <xsl:import href="utility.xslt" />

When saxon processes schemas, it may have include/import schemas, ex: <xsd:import href="mySchemaModule.xsd" /> <xsl:include href="mySchemaUtils.xsd" />

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";
    }
};

seanmcilvenna avatar Aug 04 '15 05:08 seanmcilvenna

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 <[email protected] mailto:[email protected]> 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.

ond1 avatar Aug 04 '15 07:08 ond1

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

rimmartin avatar Aug 04 '15 13:08 rimmartin

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

rimmartin avatar Aug 04 '15 13:08 rimmartin