Linux command line tool validating XSD 1.1?
Asked Answered
F

4

5

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

Xmllint does not validate version 1.1.

Fayefayette answered 13/9, 2013 at 9:21 Comment(1)
xmllint feature request: gitlab.gnome.org/GNOME/libxml2/-/issues/796Iolite
C
2

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

Celtic answered 15/9, 2013 at 23:31 Comment(3)
It seems to say here that Xerces J only supports XML 1.0 ? xerces.apache.org/xerces-jAviles
The page you point to is about Xerces J 1.4.4, released in 2001. The release notes suggest that support for XSD 1.1 was first added experimentally in release 2.7.0 of Xerces J (current release appears to be 2.11.0).Celtic
Also don't confuse XML 1.0 with XSD 1.0Rezzani
G
5

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

Gaddy answered 17/4, 2015 at 21:2 Comment(1)
Since Sep 30, 2018, the source code for the jar is available on GitHub. You can build the jar yourself using Maven (mvn package).Raiment
C
2

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

Celtic answered 15/9, 2013 at 23:31 Comment(3)
It seems to say here that Xerces J only supports XML 1.0 ? xerces.apache.org/xerces-jAviles
The page you point to is about Xerces J 1.4.4, released in 2001. The release notes suggest that support for XSD 1.1 was first added experimentally in release 2.7.0 of Xerces J (current release appears to be 2.11.0).Celtic
Also don't confuse XML 1.0 with XSD 1.0Rezzani
S
0

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
    
Stuffing answered 24/4, 2017 at 13:31 Comment(0)
D
0

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.

Dansby answered 12/6, 2019 at 19:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.