feat: integrate XSLT Tools with toolbox portal
This commit is contained in:
@@ -6,7 +6,12 @@ import {
|
||||
availableTransformEngines,
|
||||
runTransformation,
|
||||
} from '../src/transform/transformService';
|
||||
import { compileXsltTextToSefJson } from '../src/transform/saxonJsDynamicCompiler';
|
||||
import { createSha256Hash } from '../src/transform/hash';
|
||||
import type { TransformRequest } from '../src/transform/transformTypes';
|
||||
import {
|
||||
compileXsltTextToSefJson,
|
||||
resolveSaxonScriptUrl,
|
||||
} from '../src/transform/saxonJsDynamicCompiler';
|
||||
|
||||
const xmlText = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<library>
|
||||
@@ -36,6 +41,17 @@ const xslt30Text = `<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>`;
|
||||
|
||||
async function runTrustedTransformation(request: TransformRequest) {
|
||||
const revision = 1;
|
||||
return runTransformation(request, {
|
||||
trustedStylesheet: {
|
||||
hash: await createSha256Hash(request.xsltText),
|
||||
revision,
|
||||
},
|
||||
currentRevision: revision,
|
||||
});
|
||||
}
|
||||
|
||||
beforeAll(() => {
|
||||
if (window.SaxonJS) return;
|
||||
|
||||
@@ -59,6 +75,12 @@ describe('transform engine registry', () => {
|
||||
});
|
||||
|
||||
describe('SaxonJS dynamic compiler', () => {
|
||||
it('resolves the vendored runtime relative to a nested app deployment', () => {
|
||||
expect(
|
||||
resolveSaxonScriptUrl('./', 'https://example.test/deep/nested/app/')
|
||||
).toBe('https://example.test/deep/nested/app/vendor/saxon/SaxonJS2.js');
|
||||
});
|
||||
|
||||
it('compiles raw XSLT text to SEF JSON', async () => {
|
||||
const sef = await compileXsltTextToSefJson(xslt30Text);
|
||||
const parsed = JSON.parse(sef) as { N?: string; target?: string };
|
||||
@@ -68,7 +90,7 @@ describe('SaxonJS dynamic compiler', () => {
|
||||
});
|
||||
|
||||
it('runs an XSLT 1.0 stylesheet', async () => {
|
||||
const result = await runTransformation({
|
||||
const result = await runTrustedTransformation({
|
||||
xmlText,
|
||||
xsltText: xslt10Text,
|
||||
engine: 'saxon-js-dynamic',
|
||||
@@ -82,7 +104,7 @@ describe('SaxonJS dynamic compiler', () => {
|
||||
});
|
||||
|
||||
it('runs an XSLT 2.0 stylesheet with XPath 2.0 functions', async () => {
|
||||
const result = await runTransformation({
|
||||
const result = await runTrustedTransformation({
|
||||
xmlText,
|
||||
xsltText: xslt20Text,
|
||||
engine: 'saxon-js-dynamic',
|
||||
@@ -95,7 +117,7 @@ describe('SaxonJS dynamic compiler', () => {
|
||||
});
|
||||
|
||||
it('runs an XSLT 3.0 stylesheet with xsl:mode on-no-match', async () => {
|
||||
const result = await runTransformation({
|
||||
const result = await runTrustedTransformation({
|
||||
xmlText,
|
||||
xsltText: xslt30Text,
|
||||
engine: 'saxon-js-dynamic',
|
||||
@@ -109,7 +131,7 @@ describe('SaxonJS dynamic compiler', () => {
|
||||
});
|
||||
|
||||
it('returns diagnostics for invalid XSLT', async () => {
|
||||
const result = await runTransformation({
|
||||
const result = await runTrustedTransformation({
|
||||
xmlText,
|
||||
xsltText: '<xsl:stylesheet version="3.0">',
|
||||
engine: 'saxon-js-dynamic',
|
||||
|
||||
Reference in New Issue
Block a user