Code Monkey home page Code Monkey logo

xslt-lint's Introduction

XSLT Lint

So CodeKit 3 was just released and the Hooks feature is now perfect for me to try this something I'd contemplated for some time now...

Basically, I'll use XSLT to process an XSLT stylesheet when it's saved, just to find some of the most basic errors that pops up, from time to time. E.g., managing to save a non-well-formed file (it happens) or writing a clever thing where you use call-template to render something and then when you went to write the template, you used your match template snippet instead.

This initial linter catches some of those things.

(Note: The well-formedness error is actually caught by the XML parser when it tries to load the stylesheet. Just so you don't waste a lot of time digging for that :-)

CodeKit Hooks setup

Here's the Bash script I whipped together for this:

msg=$(xsltproc --xinclude $PATH_TO_XSLT_LINT_FILE $CK_INPUT_PATH)
if [[ "" = "$msg" ]]; then
	exit 0
else
	echo $msg >&2
	exit 1
fi

Note: You'll need to replace $PATH_TO_XSLT_LINT_FILE with the full path to the XSLTLint.xslt file, wherever you chose to install it (mine's in ~/Development/lib/ somewhere...)

It's set up as a Shell Script hook to execute when a file is processed and its Filename Ends With .xslt

CodeKit Languages setup

You also need to configure XSLT as one of the "Other" languages in CodeKit, so CodeKit knows that if an XSLT file is saved, it should be processed somehow. I've set it up like this:

CodeKit 3 Languages setup for XSLT

WIP

This is a work in progress, obviously - let me know if you have any questions!

Chriztian Steinmeier, October 2016.

xslt-lint's People

Contributors

greystate avatar

Stargazers

 avatar

Watchers

 avatar  avatar

xslt-lint's Issues

Add check for missing template mode

If an apply-templates instruction is using a mode there should be a template with that same mode, either in the stylesheet or one of its imports/includes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.