On Mon, Feb 10, 2014 at 9:52 PM, <p...@raf.org> wrote:

> 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?
>

You haven't done anything wrong; it's just that not all error messages are
as informative.  If the automata-based content model was violated for a
complex type, you'd see the sort of detail shown in the user manual: those
errors tend to be complex and need that level of detail to be understood.

For a facet violation the current message is only what you see.  Without
seeing the schema I can't interpret it other than it appears there's a
local simpleType used as a nested element (so it has no XML name as a type)
that requires something longer than an empty string.  (The message is "by
value %s", which could be improved so the absence of a value is more clear.)

SimpleFacetValueError is not an UnrecognizedContentError.  You can see the
exception hierarchy at:
http://pyxb.sourceforge.net/userref_validating.html#runtime-exception-hierarchy

The API is at: http://pyxb.sourceforge.net/api/index.html

>From there you can go into pyxb.exceptions_ and see that
SimpleFacetValueError has properties for the type, value, and the facet
that was violated.  You should be able to print e.location to see the
line/column in the input where the problem was identified.

You can also print e.type._location() to see where in the schema the
anonymous type appears, or delve into e.facet to find what its minimum
length is.  You can also look at the generated bindings; the definition for
STD_ANON_12 should also tell you where in the schema the definition
occurred and the minimum length for an acceptable 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)?
>

Yes.  That is not a function that PyXB supports.

Peter
------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
pyxb-users mailing list
pyxb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyxb-users

Reply via email to