diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 611b452..85e5fca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v5 with: - cache: 'npm' + cache: "npm" - name: Install dependencies run: npm ci diff --git a/.vscode/launch.json b/.vscode/launch.json index 212c6d0..cbeff36 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,12 +6,7 @@ "request": "launch", "name": "Debug Jest Currently select test name", "program": "${workspaceFolder}/node_modules/.bin/jest", - "args": [ - "--runInBand", - "--no-coverage", - "-t", - "${selectedText}" - ], + "args": ["--runInBand", "--no-coverage", "-t", "${selectedText}"], "console": "integratedTerminal", "sourceMaps": true }, @@ -20,10 +15,7 @@ "request": "launch", "name": "Debug Jest Tests", "program": "${workspaceFolder}/node_modules/.bin/jest", - "args": [ - "--runInBand", - "--no-coverage" - ], + "args": ["--runInBand", "--no-coverage"], "console": "integratedTerminal", "sourceMaps": true }, @@ -32,13 +24,9 @@ "request": "launch", "name": "Debug Jest Current File", "program": "${workspaceFolder}/node_modules/.bin/jest", - "args": [ - "--runInBand", - "--no-coverage", - "${fileBasenameNoExtension}" - ], + "args": ["--runInBand", "--no-coverage", "${fileBasenameNoExtension}"], "console": "integratedTerminal", "sourceMaps": true } ] -} \ No newline at end of file +} diff --git a/README.md b/README.md index 82ec87d..eebe234 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,25 @@ XJSLT runs in javascript runtimes and on the browser. It has been tested with [n ## Installation: ``` -npm install && npm run build +npm install -g xjslt +``` + +Or use + +``` +npx xjslt … +``` + +or from source: + +``` +git clone https://github.com/egh/xjslt.git && cd xjslt ``` ## Command line invocation: ``` -xjslt run jats-html.xsl <(curl -s https://jats.nlm.nih.gov/publishing/tag-library/1.1/FullArticleSamples/bmj_sample.xml) +xjslt run <(curl -s https://raw.githubusercontent.com/egh/xjslt/refs/heads/main/jats-html.xsl) <(curl -s https://jats.nlm.nih.gov/publishing/tag-library/1.1/FullArticleSamples/bmj_sample.xml) ``` # Compilation examples @@ -26,6 +38,8 @@ XJSLT can compile XSLT stylesheets into executable JavaScript code, which can th ## In the browser +For the following commands you will want to have the source checked out. + ``` xjslt compile --web jats-html.xsl examples/html/transform.js ``` @@ -34,9 +48,12 @@ xjslt compile --web jats-html.xsl examples/html/transform.js ## For reuse in the command line +Pre-compiling a `.js` file will speed up transformation. + ``` xjslt compile jats-html.xsl ``` + ``` xjslt run transform.js <(curl -s https://jats.nlm.nih.gov/publishing/tag-library/1.1/FullArticleSamples/bmj_sample.xml) ``` @@ -50,15 +67,19 @@ XJSLT can be used to compile XSLT into JavaScript that can be used in, for examp ``` xjslt compile --standalone jats-html.xsl examples/google-cloud/transform.js ``` + ``` cd examples/google-cloud ``` + ``` npm install ``` + ``` npx @google-cloud/functions-framework --target=transform ``` + - Visit http://localhost:8080/?url=https://jats.nlm.nih.gov/publishing/tag-library/1.1/FullArticleSamples/bmj_sample.xml ## In a cloudflare edge function @@ -66,20 +87,24 @@ npx @google-cloud/functions-framework --target=transform ``` xjslt compile --standalone jats-html.xsl examples/cloudflare/src/transform.js ``` + ``` cd examples/cloudflare ``` + ``` npm install ``` + ``` npm run start ``` + - Visit http://localhost:8787/?url=https://jats.nlm.nih.gov/publishing/tag-library/1.1/FullArticleSamples/bmj_sample.xml # Supported features -All core features of XSLT 2.0. Roughly 50% of tests in the XSLT test suite (https://github.com/w3c/xslt30-test) pass - but many of these tests are for edge cases. +All core features of XSLT 2.0. Roughly 50% of tests in the XSLT test suite (https://github.com/w3c/xslt30-test) pass - but many of these tests are for edge cases. # Incompletely supported features @@ -94,17 +119,14 @@ All core features of XSLT 2.0. Roughly 50% of tests in the XSLT test suite (htt # Running tests -The test suite includes both unit tests and a subset of the [W3C XSLT 3.0 test suite](https://github.com/w3c/xslt30-test). To run tests: +The test suite includes both unit tests and a subset of the [W3C XSLT 3.0 test suite](https://github.com/w3c/xslt30-test). To run tests, ensure dependencies are installed: -1. Clone the W3C test suite into the project root: -``` -git clone --depth=1 https://github.com/w3c/xslt30-test.git -``` -2. Build (including preprocessors): ``` -npm run build-preprocessors +npm install ``` -3. Run tests: + +and then run: + ``` npm test ``` diff --git a/package.json b/package.json index acfa51b..ef35828 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "scripts": { "build": "tsc && chmod +x dist/cli.js", "prebuild-preprocessors": "npm run build && rm src/preprocess/*js", - "build-preprocessors": "bash -c \"for n in src/preprocess/*xsl ; do npm exec -- xjslt compile --standalone \\$n \\${n/xsl/js} ; done\"", + "build-preprocessors": "bash -c \"for n in src/preprocess/*xsl ; do npm exec -- xjslt compile --standalone \\$n \\${n/xsl/js} ; done\"", "postbuild-preprocessors": "prettier -w src/preprocess/ && npm run build", "pretest": "if [ -d xslt30-test ] ; then cd xslt30-test && git pull && cd .. ; else git clone --depth 1 https://github.com/w3c/xslt30-test/ ; fi", "test": "jest --coverage --verbose",