• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Instructions on How to revalidate a DOM Tree

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Took me a long time to figure it out. But I think I have, u convert the DOM Tree to a string, then use a StringReader inside an Input Source. You now have an input source that you can feed back into a parser.
Wanted to share my discovery.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rob. You're right it is not very intuitive since people usually think of an XML document as a physical file on the hard disck. The fact of the matter is, XML documents can also be represented as in-memory strings and the parser doesn't really care!
I use DOM tree dumps to create "snapshots" of an XML document for crash recovery. The document writes itself after every mutation while it undergoes in-memory transistions. This way if something bad happens( say your computer crashes ), all you have lost is just one transition.
Cheers!
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
 
Rob Bass
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I searched high and low on the net on how to revalidate a DOM Tree, but no where could I find anything expect an old revalidating parser for xml4j that no longer exists. We thought maybe we would have to write the DOM Tree to disk then read it back in and parse it, we could not do that as the I/O would have killed the performace on our system.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried parsing the DOM tree with validation turned on and some how inserting an external DTD or Schema reference? I wonder if that is going to be difficult
 
Rob Bass
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Xerces which does PARTIAL schela validation. It seems to be working fine. Clients basically pass me in a Document Object, which I then reparse against a Schema to make sure whatever change they have done is valid. I don't know why validation is so stressed on read, validation should be done when a DOM tree is saved. You want to make sure you are saving a valid XML Document.
 
reply
    Bookmark Topic Watch Topic
  • New Topic