Sorry, my e-mail had files attached to it, and the xml file was the document in 
question. 
Anyway, the offending line is:

         <COMP_NAME>IDES México, S.A. de C.V.</COMP_NAME>

As you can see, there are 25 characters in this element, but xmlbeans thinks 
there are 26.

Thanks,
Elvira

-----Original Message-----
From: Radu Preotiuc-Pietro [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 23, 2007 4:33 PM
To: [email protected]
Subject: Re: trouble validating UTF-8 document with internationalcharacters - 
please help!

It would be more interesting to see the document in question at the line
and column referenced in the error message: is that string longer than
the declared maxLength facet?

(I wouldn't take XmlSpy as reference, since it is known to be
unreliable)

Radu

On Mon, 2007-07-23 at 15:57 -0400, [EMAIL PROTECTED] wrote:
> Hello,
> 
>  
> 
> I am using XmlBeans to validate a document against its schema.
> 
> It works fine, except when international characters are used in the
> document.
> 
> For the attached document and the corresponding schema, the error
> message is as following:
> 
>  
> 
> Node: COMP_NAME, Line: 148, Column: 10, Detail: string length (string) is 
> greater than maxLength facet (26) for 25
>   Document encoding is: null
>  
> This document is validated with XmlSpy. What am I missing? The document file 
> was written as UTF-8. 
> 
>  
> 
> The code follows. Thanks so much for your help. 
> 
>  
> 
>       private boolean xmlBeanValidate(File xmlFile, List sdocs) {
> 
>             XmlObject[] schemas = (XmlObject[]) sdocs.toArray(new
> XmlObject[0]);
> 
>             SchemaTypeLoader sLoader;
> 
>             Collection compErrors = new ArrayList();
> 
>             XmlOptions schemaOptions = new XmlOptions();
> 
>             schemaOptions.setErrorListener(compErrors);
> 
>  
> 
>            try {
> 
>                   sLoader = XmlBeans.loadXsd(schemas, schemaOptions);
> 
>             } catch (Exception e) {
> 
>                  if(compErrors.isEmpty() || !(e instanceof
> XmlException)) {
> 
>                         e.printStackTrace();
> 
>                   }
> 
>                   logError("Schema is invalid");
> 
>                  for (Iterator i = compErrors.iterator();
> i.hasNext();)
> 
>                         log(i.next().toString());
> 
>                  return false;
> 
>             }
> 
>  
> 
>             XmlObject xobj = null;
> 
>            try {
> 
>                   Reader sr = newFileReader(xmlFile);
> 
>                   XmlOptions opt = new XmlOptions();
> 
>                   opt.setCharacterEncoding("UTF-8");
> 
>                   opt.setLoadLineNumbers();
> 
>                   xobj = sLoader.parse(sr, null, opt);
> 
>             } catch (Exception e) {
> 
>                   logError("xml not loadable: " + e);
> 
>                   e.printStackTrace();
> 
>                  return false;
> 
>             }
> 
>  
> 
>             Collection errors = new ArrayList();
> 
>            if(xobj.schemaType() == XmlObject.type) {
> 
>                   logError("xml is NOT valid. Document type not
> found.");
> 
>                  return false;
> 
>             } else if (xobj.validate(new
> XmlOptions().setErrorListener(errors))){
> 
>                   log("Document validation completed successfully.");
> 
>                  return true;
> 
>             }else {
> 
>                  for (Iterator it = errors.iterator(); it.hasNext();)
> {
> 
>                         XmlError xmlError = (XmlError)it.next();
> 
>                     logError("  Node: " 
> 
> 
> +xmlError.getCursorLocation().getDomNode().getNodeName()
> 
>                               +", Line: " + xmlError.getLine()
> 
>                               +", Column: " + xmlError.getColumn()
> 
>                               +", Detail: " + xmlError.getMessage());
> 
>                     logError("  Document encoding is: " 
> 
> 
> +xobj.documentProperties().getEncoding());
> 
>  
> 
>                   }
> 
>                  return false;
> 
>             }
> 
>       }
> 
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

Notice:  This email message, together with any attachments, may contain 
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated 
entities,  that may be confidential,  proprietary,  copyrighted  and/or legally 
privileged, and is intended solely for the use of the individual or entity 
named in this message. If you are not the intended recipient, and have received 
this message in error, please immediately return this by email and then delete 
it.

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