There is no direct way to validate a DOM document in memory against a DTD. Only the parser is able to validate a document, which happens at the time the document is being read.
So what you are doing already is the probably your best option. Adding some new facility to do what you want is on everyone's wish list, but it's unclear when it will happen. -- Andy ----- Original Message ----- "Eric SCHAEFFER" <[EMAIL PROTECTED]> wrote > > I want to validate a document while I'm creating it. I've got a DTD, and > elements are required to have attributes or children of certain type. > But during construction, the existance of this attributes or children isn't > tested, of course. And I don't know how to tell "someone" that the document > is finished, and that the validation process should be perfomed. > > For now, I serialize the document to a string, and use the parser to do the > validation process. But it's a bit long and complicated for just > validation... > > Do you know a shorter way ? >