The following code snippet should give you much better information about
the errors:
...
    XmlOptions xmlOptions = new XmlOptions();
    ArrayList errorC = new ArrayList();
    xmlOptions.setErrorListener(errorC);

    
    StringBuffer sb = new StringBuffer();
    if (!xmlObj.validate(xmlOptions)) {
      Iterator i = errorC.iterator();
      sb.append("\nErrors: \n");
      for (; i.hasNext(); ) {
        XmlError xmlError = (XmlError)i.next();
        sb.append("  Node: " +
xmlError.getCursorLocation().getDomNode().getNodeName());
        sb.append(", Detail: " + xmlError.getMessage());
        sb.append("\n");
      }
    }
...

Hope this helps.

Lei


-----Original Message-----
From: Edward Frederick [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 03, 2006 11:32 AM
To: user@xmlbeans.apache.org
Subject: Re: [2.0] validation

I was wondering the same thing, actually.

I bet there's not much hope outside of traversing the model directly
so you know where the validation failures occur.

Look forward to hearing the responses.

Ed

On 3/3/06, Nathaniel Auvil <[EMAIL PROTECTED]> wrote:
> When i validate my XmlObject, i get a cryptic message as in: error:
> cvc-maxLength-valid.1.1: string length (string) is greater than
maxLength
> facet (9) for '2'
>
> How do i get more information, as in, the specific element which is
invalid
> so i can tell the user that: "hey, the: 'userName' element is too big"
>
> when i try to use the other methods on the XmlError type i get:
> error.getMessage()= error: cvc-maxLength-valid.1.1: string length
(string)
> is greater than maxLength facet (9) for '2'
> error.getSourceName()= null
> error.getCursorLocation().xmlText()= <xml-fragment xmlns=""/>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to