[pyxb-users] validation errors not as described
Brought to you by:
pabigot
From: <py...@ra...> - 2014-02-11 03:52:23
|
hi, i've just installed pyxb-1.2.3 into python-2.7 (via macports) on macosx-10.6.8 to validate xml documents against an xsd file but the validation errors that i'm seeing are not the nice informative ones as described in: http://pyxb.sourceforge.net/userref_validating.html instead of seeing line/column numbers and element names, i'm seeing: pyxb.exceptions_.SimpleFacetValueError: Type <class 'sampleschema.STD_ANON_12'> minLength constraint violated by value btw, the code supplied in the url above assumes that the exception will be pyxb.UnrecognizedContentError but pyxb.exceptions_.SimpleFacetValueError doesn't seem to be a subclass of that. any idea what i've done wrong? i generated the module with: $ pyxbgen -u sample-schema.xsd -m sampleschema Python for AbsentNamespace0 requires 1 modules and the client code is: import sys, pyxb, sampleschema if len(sys.argv) != 2: print('usage: %s sample.xml' % sys.argv[0]) exit(0) xmlbytes = open(sys.argv[1]).read() xmlparsed = None try: xmlparsed = sampleschema.CreateFromDocument(xmlbytes) except pyxb.UnrecognizedContentError as e: print('Error validating XML\n%s' % e.details()) except Exception as e: print('Unknown XML validation error\n%s\n%s' % (type(e), e.details())) which outputs: Unknown XML validation error <class 'pyxb.exceptions_.SimpleFacetValueError'> Type <class 'sampleschema.STD_ANON_12'> minLength constraint violated by value also, am i right in thinkng that there is no way to obtain a list of all validation errors in a document (like xmllint)? thanks, raf |