Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how xml file is checked against dtd at run time

 
yo nara
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suppose i have written java code for reading xml file.and xml file is created by some one else , then is that xml file checked against dtd automatically .so that i could not get error at run time or have i need to write some code for checking against dtd before parsing the java file.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The parser uses the DOCTYPE definition in the xml file to first determine whether the document has an associated DTD. If so, and if the validation is turned on, the parser automatically "parses the dtd" and then esures that the XML conforms to the DTD structure.
Hope that answers your question.
 
yo nara
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for reply
i got error by using following methods
setValidating(true);
setErrorHandler(some class);
but now i want to check wheather the value in xml file is single byte or double byte
how should i write the schema file
 
Senthil Kumar Sekar
Ranch Hand
Posts: 45
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry to post in the old thread.But my question is a continuation.

If a DTD is defined and if you have say "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd", how does the parser checks if i do not have an internet connection in my pc? Does that works that way?

Could you please tell me how the DTD is validated by any parser?

Thanks.

Regards
Senthil Kumar Sekar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic