posted 12 years ago
[1]
>Normally xml has its DTD which defines the structure that an XML should have.
I am not sure where do you get that idea. But you say "normally", and it puts enough safety net on the validity of the statement. "Abnormally" might swing the balance far off the other way, but I would say "normally xml does not have its DTD...".
>This ensures the xml is not violating any syntaxes.
DTD is quite incapable to ensure the xml not violating "any syntaxes" (whatever it means).
>Validating xml against DTD is done when the xml is parsed by any parser(DOM,SAX etc.,)
It can be done when, but it can be not doing it when, neither. "by any parse" is an undue optimism. Not every parser is a validating parser.
[2]
>In XML, the DTD location is mentioned as www.xx.com --> how does the parser validates if the DTD resides in some other server
It will fetch it if so required. And the location is not necessarily mentioned as www.xx.com.
>and it [sic, if] there is no internet connection in the pc, the parser is ran.
If the fetching requires internet connect and there is lacking, it will be a runtime error if no measure is taken to guard against.