Skip to content
Clojure library for validating XML documents according to XSD schemas
Branch: master
Clone or download
Pull request Compare This branch is 11 commits ahead of rkday:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A fork of the xml-validation library, created by rkday.

A Clojure library designed to wrap the Java libraries for XML schema validation. create-validation-fn takes a schema, and returns a function that takes an XML string and returns true (if the string is valid according to the schema) or false.

Improves on the original implementation of this library by:

  • Accept the schema to validate against using anything that the StreamSource constructor can handle (e.g an InputStream, Reader, File etc.) + URL
  • Returns a ValidationResult object, that encloses the validation errors


Clojars Project


(require '[clj-xml-validation.core :as xmlv])
(def is-valid-xml? (xmlv/create-validation-fn ( "example.xsd")))

(xmlv/valid? (is-valid-xml? "<foo><bar/></foo>"))
;; => true or false

(xmlv/errors (is-valid-xml? "<foo><bar/></foo>"))
;; => vector of {}'s - for example:
;; {:message "cvc-complex-type.2.4.a: Invalid content was found starting with element 'heading'. One of '{from}' is expected."
;;  :line-number 1
;;  :column-number 50
;;  :source "...SNIP..."}

;; Validating malformed xml throws an exception
(is-valid-xml? "<foo><bar/>")
;; => throws clojure.lang.ExceptionInfo


lein do clean, test, install


Forked by Brendan Bates - ICM Consulting

Original Copyright © 2013 Rob Day

Distributed under the Eclipse Public License, the same as Clojure.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.