Saturday, October 3, 2015

Validating XML against an XSD with xmllint

Quick reference for how to validate an XML document against a schema using xmlint:
  $ xmllint --noout --schema stats.xsd example-stat.xml 
  example-stat.xml validates
Here is what you might see for an invalid document:
  $ xmllint --noout --schema stats.xsd junk.xml
  junk.xml:1: element event: Schemas validity error : Element 'event': No matching global declaration available for the validation root.
  junk.xml fails to validate

Thursday, October 1, 2015

Groovy: Closure Currying Example

Really simple example of closure currying so I do not forget it and hope that it helps someone else:
def addTo = { Map m, String k, Object v ->
    m[k] = v

Map elements = [:]

addTo elements, 'a', 1

def addTo2 = addTo.curry(elements)

addTo2 'c', 3

assert elements == ['a':1, 'c':3]