The moose likes XML and Related Technologies and the fly likes Why qualified XML elements are erroring out ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Why qualified XML elements are erroring out ?" Watch "Why qualified XML elements are erroring out ?" New topic

Why qualified XML elements are erroring out ?

Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 547

Hello All,

I have an xsd as given below,

I have few questions based on the above scheme.

1) Let us assume that a sample XML is generated with Person as root

If in the above example, if I use qualified names for the elements "firstName", "lastName","age","favColour" it is throwing a validation error

"*** ErrorHandler.error() : cvc-complex-type.2.4.a: Invalid content was found starting with element 'ivan:firstName'. One of '{firstName}' is expected. at line 3"

But I add "elementFormDefault" as "qualified" and use prefixes, it is working fine.

I understand that by mandating qualifier for elements, we need to use prefixes for all elements. But why should it error, if elementFormDefault is not added and we use qualifier. Should it not rather ignore it ?

2) If I add a comment like say "<!-- A comment in the file kompisar.xml -->" after <?xml?> element and try to run a SAX parser with the following code in my handler

I see the inCharacters has a length more than what the actual comment is having and it is printing some kind of garbage. What does inCharacters has apart from the comment and why does it not display?


I agree. Here's the link:
subject: Why qualified XML elements are erroring out ?
It's not a secret anymore!