From eb530ca36f3c65d4b17063454a97a915a00518b3 Mon Sep 17 00:00:00 2001 From: SayMoon Date: Wed, 14 May 2025 08:04:58 +0200 Subject: [PATCH 1/2] Add sample --- .github/workflows/quality-check.yaml | 2 - xslt-conversion/index.ts | 56 ++++++++++++++++++++++++++++ xslt-conversion/package.json | 8 ++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 xslt-conversion/index.ts create mode 100644 xslt-conversion/package.json diff --git a/.github/workflows/quality-check.yaml b/.github/workflows/quality-check.yaml index bb17fca..7391438 100644 --- a/.github/workflows/quality-check.yaml +++ b/.github/workflows/quality-check.yaml @@ -17,8 +17,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - name: Setup Node.js uses: actions/setup-node@v3 diff --git a/xslt-conversion/index.ts b/xslt-conversion/index.ts new file mode 100644 index 0000000..b911a57 --- /dev/null +++ b/xslt-conversion/index.ts @@ -0,0 +1,56 @@ +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 new file mode 100644 index 0000000..602812c --- /dev/null +++ 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 +} From 08fee7180de1106e81f64fdaacf8c699b089aa6d Mon Sep 17 00:00:00 2001 From: SayMoon Date: Wed, 14 May 2025 08:31:39 +0200 Subject: [PATCH 2/2] Please prettier --- xslt-conversion/index.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/xslt-conversion/index.ts b/xslt-conversion/index.ts index b911a57..da681bc 100644 --- a/xslt-conversion/index.ts +++ b/xslt-conversion/index.ts @@ -27,12 +27,12 @@ export function getDescription() { 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(); @@ -43,14 +43,10 @@ export async function execute(context: Context): Promise { 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."); } - - - -