Thanks for your answer. My problem is quite strange, I have an extern validation scheme - an xsd file and I try to validate with this scheme a Document. The Document is created at run time (it is not loaded from a file). The next code snippet shows how I create the Document and its root node.
My validation does not find the root. I get an exception like : Exception in thread "main" org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'Parameterset'.
where the Parameterset is the name for my root. Even more strange if I wrote the generated document in to a file and I reload it (with docBuilder.parse(new File(file)) ) it works.
Why I can not validate the run time generated document ?
Joined: Mar 22, 2005
That's hard to say without seeing the XML and the Schema.
I am not sure this is considerable or not but you have mis spelled your method ( missing 'l' in buildRoot method name)..
Joined: Sep 18, 2003
Rahul, yes I use the XSD file for validation. The file is pretty big that why I post just one snippet. This sniper is enough to generate the SAXException (because it does not find the root node).
Ugender, thanks for tip.
In the mean time I do some research and I find a solution for my problem but I still can not explain it. It is like this : if I create the DOM document at run time and I validate it I get a SAXException but if I serialize the DOM in to a file and I parse this file back in to a DOM document, the validation works with the new parsed DOM. Quite strange. This lead me to a conclusion - the DOM build at run time is wrong, but I don't see any error. How about you guys ?