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..da681bc --- /dev/null +++ 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 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 +}