Question

Is there any command line tool that validates XML against a XSD version 1.1?

Xmllint does not validate version 1.1.

Was it helpful?

Solution 2

XSD 1.1 is currently supported by Saxon and by Xerces J. Both should run without trouble under Linux.

OTHER TIPS

I found a handy wrapper around Xerces-J: https://www.dropbox.com/s/939jv39ihnluem0/xsd11-validator.jar

java -jar xsd11-validator.jar -sf my.xsd -if my.xml

You can update the Xerces-J lib by unzipping the jar, dropping the new Xerces-J in it, then rezipping it to a jar

Reference

Edit: Updated download link

I answered this question over here at AskUbuntu.
It includes working links to the Xerces-J wrapper xsd11-validator.jar and a comfortable bash script for easy usage.

xmllint unfortunately could not support XML Schema 1.1 but alternatively it supports RelaxNG based Schema (including all the advancements similar to the XML Schema 1.1).

Following is the procedure could be used to overcome xmllint limitations:

  1. implement your validation XML Schema version 1.1 based on Oxygen Editor reverse generator (based on already existing XML files). it could be downloaded from here with the 1 month license free

  2. resulting XSD 1.1 file will not be accepted by xmllint with the following error messages:

    xmllint --schema user.xsd --noout user.xml 
    user.xsd:565: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element': Invalid value for maxOccurs (must be 0 or 1).
    user.xsd:741: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element': Invalid value for maxOccurs (must be 0 or 1).
    WXS schema user.xsd failed to compile
    

    however the xml schema could be converted into relaxng schema with the help of RNGConv tool which is a part of the Kohsuke Kawaguchi's MSV project by applying following conversion command:

    java -jar rngconv-20060319/rngconv.jar user.xsd > user.rng
    
  3. resulting relaxng schema file could be used with the xmllint:

    xmllint --relaxng user.rng --noout user.xml 
    user.xml validates
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top