J-W
J-W

Reputation: 408

integrating an xsd validator (lib or tool)

I am currently using a crossplatform c++ project (windows+linux) which will soon need an external xsd validator.

My plan is to:

I have a deep hierarchy of xsd files, so I need a solid tool for the job.

My question: I need some suggestions about some easy-to-integrate-yet-production-ready-solution.

My take for now is to use Xerces, the java version and just call it in a separate process.

Probably I need to wrap Xerces, since it seems to not allow xsd validation in the command line, directly, e.g. https://github.com/ndw/xjparse.

Thanks

Upvotes: 0

Views: 124

Answers (1)

Cole Tierney
Cole Tierney

Reputation: 10304

You could use xmllint with the --schema option:

xmllint --noout --schema test.xsd test.xml

test.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:element name="info" type="xs:string"/>
</xs:schema>

test.xml

<?xml version="1.0"?>
<info>abc</info>

Upvotes: 1

Related Questions