I ran into problems when trying to validate xml files against the according xsd schema using XercesDOMParser. It seems that the xsd file is not recognized even though it is available in the same folder together with the executable and the input file.
I can reproduce the errors by using DOMPrint.exe example and two simplified modifications of the sample xml and xsd coming along with xerces 3.0.0 and 2.8.0 (I’m using the Windows VC9 distribution). I’ve created the input files p1.xml and p2.xml as parts of the personal.xml, but referring to the personal.xsd validation. p1.xml: <?xml version="1.0" encoding="UTF-8"?> <?proc-inst-1 'foo' ?> <personnel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation='personal.xsd'> <person id="Big.Boss"> <name xml:base="foo/bar"><family xml:base="bar/bar">Boss</family> <given xml:base="car/bar">Big</given><?proc-inst-2 'foobar' ?></name> [email protected] <link subordinates=""/> </person> </personnel> p2.xml (same but “id” attribute of person Big.Boss is now “i”, so schema validation should yield an error): <?xml version="1.0" encoding="UTF-8"?> <?proc-inst-1 'foo' ?> <personnel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation='personal.xsd'> <person i="Big.Boss"> <name xml:base="foo/bar"><family xml:base="bar/bar">Boss</family> <given xml:base="car/bar">Big</given><?proc-inst-2 'foobar' ?></name> [email protected] <link subordinates=""/> </person> </personnel> When opening p1.xml, p2.xml and personal.xsd coming along with the distribution, everything is ok (the editor underlines the “person” tag in p2 stating that the required attribute “is” is missing). But validation while executing “DOMPrint.exe” either does not take place or fails because it seems that the schema is not recognized. The command line inputs “DOMPrint p1.xml” and “DOMPrint p2.xml” both yield D:\Documents and Settings\dxxx\My Documents\Xerces\Test>DOMPrint.exe p2.xml <?xml version="1.0" encoding="UTF-8" standalone="no" ?><?proc-inst-1 'foo' ?><personnel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="personal.xsd"> <person i="Big.Boss"> <name xml:base="foo/bar"><family xml:base="bar/bar">Boss</family> <given xml:base="car/bar">Big</given><?proc-inst-2 'foobar' ?></name> [email protected] <link subordinates=""/> </person> </personnel> whereas “DOMPrint -v=always p1.xml” and “DOMPrint -v=always p2.xml” yield D:\Documents and Settings\dxxx\My Documents\Xerces\Test>DOMPrint.exe -v=always p1.xml > testp1v.txt Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 3, column 11 Message: no declaration found for element 'personnel' Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 3, column 22 Message: attribute 'xmlns:xsi' is not declared for element 'personnel' Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 3, column 96 Message: attribute 'xsi:noNamespaceSchemaLocation' is not declared for elemen t 'personnel' Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 4, column 10 Message: no declaration found for element 'person' Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 4, column 14 Message: attribute 'id' is not declared for element 'person' Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 5, column 10 Message: no declaration found for element 'name' Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 5, column 20 Message: attribute 'xml:base' is not declared for element 'name' Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 5, column 37 Message: no declaration found for element 'family' Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 5, column 48 Message: attribute 'xml:base' is not declared for element 'family' Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 5, column 78 Message: no declaration found for element 'given' Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 5, column 88 Message: attribute 'xml:base' is not declared for element 'given' Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 6, column 11 Message: no declaration found for element 'email' Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 7, column 10 Message: no declaration found for element 'link' Error at file "D:\Documents and Settings\dxxx\My Documents\Xerces\Test/p1.xml" , line 7, column 24 Message: attribute 'subordinates' is not declared for element 'link' The original example with the DTD validation works fine though (i.e. it reports errors if the xml does not fit the DTD, even in the -v=auto mode). Obvious question: am I doing s.th. wrong or is this a bug? Thank you very much for any help that you can provide. Cheers, Holger -- View this message in context: http://www.nabble.com/Validation-against-xsd-scheme-with-xerces-C%2B%2Bdoes-not-take-place-or-fails-%28both-3.0.0-and-2.8.0%2C-Windows-VS-2008%29-tp24777302p24777302.html Sent from the Xerces - C - Dev mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
