You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlbeans-user@xml.apache.org by "Katzman, Anatoly" <An...@bmc.com> on 2003/12/08 06:16:49 UTC
Validation with XMLBeans
Hi,
I am currently evaluating XMLBeans (as it is available at Apache).
It looks great and surpasses all the countepart technologies, but one thing
makes me frustrated - its validation capabilities.
It is probably my mistake; I would really appreciate your help in finding it
out.
I started with a schema that defined an element of a complex type, let's
name it MyElement.
Then I compiled it with XMLBeans and got two Java classes: bean MyElement
and its document MyElementDocument.
I am now trying to validate instances of the MyElement class (after I
populated it with some values) like following:
XmlOptions opts = new XmlOptions();
opts.setValidateOnSet();
List errors = new ArrayList();
opts.setErrorListener( errors);
MyElementDocument doc = MyElementDocument.Factory.newInstance(
opts);
MyElement obj = doc.addNewMyElement();
obj.add....
obj.set...
boolean isValid = obj.validate( opts);
if (isValid) {
System.out.println ("valid");
} else {
for (int i = 0; i < errors.size(); i++) {
XmlError error = (XmlError)errors.get(i);
XmlCursor cursor =
error.getCursorLocation();
System.out.println (cursor.xmlText() +
"\n");
}
}
Indeed, the object is invalid against the schema, and I expect the error
message to pinpoint the cause of the problem.
Instead, the error text reads:
<xml-fragment/>
and this is little bit vague.
So, can I do better to have more descriptive validation messages?
Thank you,
Anatoly Katzman
- ---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/