Why does this XML validation via XSD fail in libxml2 (but succeed in xmllint) and how do I fix it?
After getting some help on the gnome project's xml mailing-list it appears as if my error is not caused by a bug of mine, but rather by a bug of OSX 10.6.x's distribution (v2.7.3) of libxml2.
(as in: same code works for others, yet fails for me OSX' legacy distribution)
I checked the libxml2 release notes and found two candidates:
Release notes of Update 2.7.4 list the following bug fix:
- "579746 XSD validation not correct / nilable groups (Daniel Veillard)"
Release notes of Update 2.7.8 list the following bug fix:
- "Fix errors in XSD double validation check (Csaba Raduly)"
Haven't yet had success getting the latest build (v2.7.8) of libxml2 to work with my project (or rather Xcode in general) though.
I tried your content and code on Ubuntu Linux. Worked without any objection.
Build command:
gcc -Wall -I/usr/include/libxml2 main.c -lxml2 -o xmlvalid
Run command:
./xmlvalid ./schema.xsd ./test.xml
Output:
XSD File: ./schema.xsdXML File: ./test.xml
XML Source:
<?xml version="1.0" encoding="UTF-8"?><foo xmlns="http://example.com/XMLSchema/1.0"></foo>
Validation successful: YES (result: 0)