From 4fa1eddace7c68eb9786635eab98815a05af0fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zl=C3=A1mal?= Date: Tue, 13 May 2025 13:16:26 +0200 Subject: [PATCH 1/2] vytvoreni file --- xslt-conversion/index.ts | 0 xslt-conversion/package.json | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 xslt-conversion/index.ts create mode 100644 xslt-conversion/package.json diff --git a/xslt-conversion/index.ts b/xslt-conversion/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/xslt-conversion/package.json b/xslt-conversion/package.json new file mode 100644 index 0000000..e69de29 From 7ed78df7d86474907fa897cf1274ee1b2586e6ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zl=C3=A1mal?= Date: Tue, 13 May 2025 13:20:39 +0200 Subject: [PATCH 2/2] create content consult description --- xslt-conversion/index.ts | 52 ++++++++++++++++++++++++++++++++++++ xslt-conversion/package.json | 8 ++++++ 2 files changed, 60 insertions(+) diff --git a/xslt-conversion/index.ts b/xslt-conversion/index.ts index e69de29..da681bc 100644 --- a/xslt-conversion/index.ts +++ b/xslt-conversion/index.ts @@ -0,0 +1,52 @@ +export function getDescription() { + return { + description: "Xslt Transformation", + input: [ + { + id: "template", + displayName: "XSLT Template", + description: "Path to the XSLT template file.", + type: "InputResource", + required: true, + }, + { + id: "xml", + displayName: "XML File", + description: "Path to the XML file.", + type: "InputResource", + required: true, + }, + { + id: "result", + displayName: "Result File", + description: "Path to the result file.", + type: "OutputResource", + required: true, + }, + ], + output: [], + } as const satisfies ScriptDescription; +} + +export async function execute(context: Context): Promise { + const templatePath = context.parameters.template as string; + const xmlPath = context.parameters.xml as string; + const resultPath = context.parameters.result as string; + + console.log(`Reading XSLT template from: ${templatePath}`); + const templateFile = context.getFile(templatePath); + const templateContent = await templateFile.read(); + + console.log(`Reading XML file from: ${xmlPath}`); + const xmlFile = context.getFile(xmlPath); + const xmlContent = await xmlFile.read(); + + console.log("Applying XSLT transformation."); + const transformedContent = runtime.xmlUtils.applyTemplate(xmlContent, templateContent); + + console.log(`Writing result to: ${resultPath}`); + const resultFile = context.getFile(resultPath); + await resultFile.write(transformedContent); + + console.log("Transformation completed successfully."); +} diff --git a/xslt-conversion/package.json b/xslt-conversion/package.json index e69de29..602812c 100644 --- a/xslt-conversion/package.json +++ b/xslt-conversion/package.json @@ -0,0 +1,8 @@ +{ + "name": "xslt-conversion", + "displayName": "XSLT conversion", + "description": "Converts a XSLT template and an XML file into a single file.", + "fromVersion": "24.10.1.1", + "toVersion": null, + "private": true +}