• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Xerces schema validation failure after changing dom  RSS feed

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi..
i have a strange problem, where if i change my xml by simply inserting another element, and trying to validate it against the schema,  will cause it to fail with the following error:

Exception in thread "main" org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element ''. One of '{MultiSite}' is expected.

if i use the xerces parser (which would be the default as i have it in my classpath) , however if i use com.suns internal schema validator (the line i remakred)  it passes

i should also add that if i turn the dom into a string and parse it back, it also works.

why?

 
Ranch Hand
Posts: 721
5
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There was a time gap between dom being started taking shape and the necessity of namespace concept. And then dom itself continued to develop as well... At the time of dom level 1, there wasn't namespace in its final shape and dom level 1 is therefore not namespace aware. And when dom developed to level 2, namespace was then fully incorporated and many other things enhanced as well such as event model. I can say though: without namespace, there is no schema validation. Hence, in the area of schema validation, namespace awareness is a must.

That said, we are in dom level 2 minimum for the validation issue. So dbf.setNamespaceAware(true) is good. However, in the construction of and/or parsing to a dom tree, it is not at all a good idea by mixing level 1 and level 2 methods. It can lead to unpredictable consequences and this is one.

This correction will take out the consequential mixing of methods in different levels and should have the problem rectified.
 
Elhanan Maayan
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wow that worked, i'm assuming everything that doesn't have  "since dom level 2" in the javadoc is considered level 1?

g tsuji wrote:There was a time gap between dom being started taking shape and the necessity of namespace concept. And then dom itself continued to develop as well... At the time of dom level 1, there wasn't namespace in its final shape and dom level 1 is therefore not namespace aware. And when dom developed to level 2, namespace was then fully incorporated and many other things enhanced as well such as event model. I can say though: without namespace, there is no schema validation. Hence, in the area of schema validation, namespace awareness is a must.

That said, we are in dom level 2 minimum for the validation issue. So dbf.setNamespaceAware(true) is good. However, in the construction of and/or parsing to a dom tree, it is not at all a good idea by mixing level 1 and level 2 methods. It can lead to unpredictable consequences and this is one.

This correction will take out the consequential mixing of methods in different levels and should have the problem rectified.

 
Sheriff
Posts: 24080
54
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that, g tsuji. The default namespace is always an easy thing to overlook.
 
Sheriff
Posts: 21602
101
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a cow for finding the solution!
 
Paul Clapham
Sheriff
Posts: 24080
54
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Elhanan Maayan wrote:wow that worked, i'm assuming everything that doesn't have  "since dom level 2" in the javadoc is considered level 1?



Well, not exactly. The changes between level 1 and level 2 are documented here; the parts which mention new methods whose names are like "...NS" are the parts which permit namespaces to be used. Those are the methods you need to be using for your situation. As you see there are other changes there but they aren't related to namespaces.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!