xmllint : validate an XML file against two XSD schemas (envelope / payload)

前端 未结 3 970
甜味超标
甜味超标 2021-02-02 13:04

I am using xmllint to do some validations and I have an XML instance document which needs to validate against two schemas: one for the outer \"envelope\" (which includes an

3条回答
  •  长情又很酷
    2021-02-02 13:46

    I quit on xmllint and used Xerces instead.

    I downloaded Xerces tarball and after exploding it to some local folder I created the following validate script based on this suggestion (from web archive - original link being now dead):

    #!/bin/bash
    XERCES_HOME=~/software-downloads/xerces-2_11_0/
    echo $XERCES_HOME
    java -classpath $XERCES_HOME/xercesImpl.jar:$XERCES_HOME/xml-apis.jar:$XERCES_HOME/xercesSamples.jar sax.Counter $*
    

    The ab.xml file is then validated, against both schemas, with the following command:

     validate -v -n -np -s -f ab.xml
    

    Xerces is reading the schema locations from the xsi:schemaLocation element in ab.xml so they don't need to be provided in the command line invocation.

提交回复
热议问题