Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 4 additions & 16 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
}
]
}
}
44 changes: 33 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
Expand All @@ -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)
```
Expand All @@ -50,36 +67,44 @@ 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

```
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

Expand All @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down