• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

XML handling in Java

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm facing a problem for which I am unable to find a correct solution. I have a XML file which I read into memory and make a DOM (using validating parser). Now I start removing certain nodes from the DOM. I want to check that each Node removal is not causing the document to be invalid against the DTD. I want to check this as and when i'm removing the nodes and if the document is becoming invalid because of theremoval then I do not want to remove the node. The only way I can think of achieving that right now is removing each node then writing the file back and again validating it by parsing through a validating parser. But that will hit the performance a lot. Can anyone suggest a better alternate, I'm sure they would be a better way.

Thanks in advance.
Nitin
 
Nitin Mehhta
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to add to my question, I know such a dynamic validation is possible in DOM3 but the environment I am using is DOM2 jdk1.4_2
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With the DOM2 standard API, there is unfortunately no way to revalidate an XML document. You can however serialize the document to text, then reparse it. However, this will have performance problems
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is possible to use DOM 3 with Java 1.4.2 if you have a DOM3-compliant XML parser like Xerces 2.7. See here and here on how to do that.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic