This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
Author

Why qualified XML elements are erroring out ?

Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 518
    
    2

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?


Regards
KumarRaja

 
 
subject: Why qualified XML elements are erroring out ?
 
Similar Threads
XML Schema Problem
Problem with mapping Array String into HashMap in Axis
JAXB - Named Complex Type is converted to Java content interface
Web Service SimpleType restrictions?
JAXWS can not add additional classes