← 全部工具

xslint/xslint

热度 65 更新于 开发与构建

XSL Linter

githubauto-collected

安装

暂未验证可直接使用的安装命令,请查看项目官方文档或 Release。

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/stylesheets

Given 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.9

Or 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: xslint

Browse 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.

Installation