You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Springer, Ian P." <ia...@hp.com> on 2004/11/01 23:45:03 UTC

RE: possible bug in XmlObject.parse()

Thanks, David. I hadn't noticed the validate() method. That should do
the trick, except for one thing.. For each validation error, validate()
sticks XmlErrors into the error printer/listener. The XmlError class
does not have a field to indicate the type of error (e.g.
MIN_OCCURS_VIOLATION, MAX_OCCURS_VIOLATION, INVALID_ATTRIBUTE, etc..).
Such a field would be valuable for application developers, because it
would all them to handle different types of errors differently. For
example, I might want to log a warning for INVALID_ATTRIBUTE errors, but
throw an exception for all other types of errors. The message String
field of XmlError can't be used, because of positional parameters and
i18n.

What do you think?

Thanks,
Ian

| -----Original Message-----
| From: David Jencks [mailto:david@coredevelopers.net] 
| Sent: Thursday, October 28, 2004 12:19 PM
| To: dev@xmlbeans.apache.org
| Subject: Re: possible bug in XmlObject.parse()
| 
| Why not use the validate method, present and working in v1?  
| You can get it to give you a nice explicit list of validation 
| problems.
| 
| The nice thing about not validating during parse is that then 
| you can go through using xmlcursors and fix up the xml before 
| you try to validate.  Kind of odd to do, but you can do 
| things like putting various elements in different namespaces. 
|  This can make life simpler for both the guy who has to write 
| the xml and the one writing the code using xmlbeans.
| 
| david jencks
| 
| On Oct 28, 2004, at 7:55 AM, Springer, Ian P. wrote:
| 
| > This is an issue for us because if the contents of the XML being 
| > parsed do not match the schema, the subelement names in the 
| XmlObject 
| > returned by parse() match the schema and not the XML that 
| was passed 
| > in. Are there any plans for v2 to add an option to parse() that 
| > enables validation?
| >
| > Thanks,
| > Ian
| >
| > ________________________________
| >
| > From: Kevin Krouse [mailto:kkrouse@bea.com]
| > Sent: Wed 10/27/2004 11:13 PM
| > To: dev@xmlbeans.apache.org
| > Subject: RE: possible bug in XmlObject.parse()
| >
| >
| >
| > When parsing a *Document type, only the root element's 
| QName matters.
| > If the QName of the root element is correct, a new instance of 
| > FooDocument (or whatever) will be created.  XmlBeans lazily creates 
| > XmlObjects when they are requested, so no type information is known 
| > about the subelement until you ask for it.  It isn't 
| required that an 
| > instance of some generated type to be valid for you to use it.  In 
| > fact, no validation is done during parsing at all.
| >
| > I hope my explanation makes sense...
| >
| > --k
| >
| > -----Original Message-----
| > From: Springer, Ian P. [mailto:ian.springer@hp.com]
| > Sent: Tuesday, October 26, 2004 1:18 PM
| > To: xmlbeans-dev@xml.apache.org
| > Subject: possible bug in XmlObject.parse()
| >
| > When I call parse() on an XML document Foo.xml whose root element 
| > matches a loaded schema Foo.xsd's root element, but with a 
| subelement 
| > that has a different namespace than the subelement defined in the 
| > schema, I'd expect parse() to return an XmlAnyType, but instead it 
| > returns the generated type for Foo.xsd. See the attached test case 
| > that demonstrates this behavior. Please let me know if this 
| is indeed 
| > a bug, and if so, if there is any workaround. If you concur 
| that it's 
| > a bug, I'll file a Jira issue.
| >
| > Thanks!
| > Ian
| >
| > 
| ---------------------------------------------------------------------
| > To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
| > For additional commands, e-mail: dev-help@xmlbeans.apache.org
| >
| >
| >
| > 
| <winmail.dat>---------------------------------------------------------
| > -
| > -----------
| > To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
| > For additional commands, e-mail: dev-help@xmlbeans.apache.org
| 
| 
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
| For additional commands, e-mail: dev-help@xmlbeans.apache.org
| 
| 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org