Project

Profile

Help

Support #6101

closed

xsl:import pathing

Added by John Cotton 11 months ago. Updated 7 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2023-06-28
Due date:
% Done:

100%

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

Description

Hello

I'm running some Node on AWS Lambda, but struggling to get xsl:imports to work there.

My sources are both strings, with the XSL being XSL rather than compiled SEF.

This code works locally, when supplying a (Windows) path as TEMP_DIR.

const transformXml = (xml, xsl) => {
	try {
		const env = SaxonJS.getPlatform();
		const xslDoc = env.parseXmlFromString(xsl);

		// hack: avoid error "Required cardinality of value of parameter $static-base-uri is exactly one; supplied value is empty"
		xslDoc._saxonBaseUri = `file://${TEMP_DIR}`;

		const sef = SaxonJS.compile(xslDoc);

		const result = SaxonJS.transform({
			stylesheetInternal: sef,
			sourceText: xml,
			logLevel: 1,
		});

		return SaxonJS.serialize(result.principalResult, { method: "xml" });
	} catch (error) {
		console.error(`Transform err: ${error.message}`);
	}
};

However, on Lambda, when the files that are xsl:import[ed] sit in /tmp, I get a "can't load file" error.

Where am I going wrong? Is SaxonJS.getResource a better approach? If so, could you point me to an example - I'm struggling to get something based on your docs working.

Regards John

Please register to edit this issue

Also available in: Atom PDF Tracking page