xslint
Lint your XSL/XSLT stylesheets — catch malformed XML, invalid XPath, and stylistic defects before they ship.
xslint is a CLI linter for XSL stylesheets. It first checks that every stylesheet is well-formed and every XPath expression compiles, then runs its checks for stylistic, semantic, and logical problems — each reported with its exact line and column, in your terminal or in CI.
Quick start
Run it on your stylesheets — no install needed:
npx @maxonfjvipon/xslint@0.0.14 path/to/stylesheetsGiven a stylesheet like this:
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="//book">
<xsl:variable name="x" select="title"/>
<xsl:value-of select="$x"/>
</xsl:template>
</xsl:stylesheet>xslint points at each problem with its exact position and how to fix it:
[ERROR] sheet.xsl(2:1) The xsl:output instruction is missing. Declare it to specify the serialization format explicitly. (not-using-output)
[WARNING] sheet.xsl(3:3) The match attribute of xsl:template starts with //, which scans the entire document tree. Use a more specific pattern. (starts-with-double-slash)
[WARNING] sheet.xsl(4:5) A variable, function, or template has a single-character name. Use a descriptive name that reveals intent. (short-names)In CI, use the GitHub Action to get inline annotations on your pull requests:
- uses: actions/checkout@v6
- uses: xslint/xslint-action@0.0.9Or run it on commit with pre-commit — add to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/xslint/xslint
rev: 0.0.11
hooks:
- id: xslintBrowse the full check catalog.
Proven on real code
Pointed at core stylesheets from the three most widely-used XSLT projects — DocBook-XSL (1.0), TEI (2.0), and DITA-OT (1.0/2.0), 70 files in all — xslint surfaced 1,974 findings across 22 different checks, with no false positives from its validators: 106 xsl:choose blocks with no xsl:otherwise, 67 unused named templates, 40 stylesheet functions never called, and more. Real stylistic and logical findings in code that has shipped for decades.