• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why qualified XML elements are erroring out ?  RSS feed

Kumar Raja
Ranch Hand
Posts: 548
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!