File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes XML and DTD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML and DTD" Watch "XML and DTD" New topic
Author

XML and DTD

Senthil Kumar Sekar
Ranch Hand

Joined: Aug 08, 2010
Posts: 45

Hi All,

Below is my understanding about 2 points about XML.Please correct me if am wrnog.

1) Normally xml has its DTD which defines the structure that an XML should have.This ensures the xml is not violating any syntaxes.
Validating xml against DTD is done when the xml is parsed by any parser(DOM,SAX etc.,)

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 and it there is no internet connection in the pc, the parser is ran.


Thanks.

Regards
Senthil Kumar Sekar
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 507
    
    3
[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.
Senthil Kumar Sekar
Ranch Hand

Joined: Aug 08, 2010
Posts: 45

Iam not getting your point Tsu.

Let me put my understand.please let me knw if am wrong.

1. DTD and XSD are used to define the structure of an XML.
2. Certain parsers will be able to validate the syntax if setValdating(true)

If DTD in another server

For instance hibernate mapping xml has this

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"

I guess the dtd for mapping is available in another server.
But still iam able to run the application without any prob.
1. Does this requires an internet connection?
2. Validating the xml blocks is not done in Hibernate ?

Can you make me to understand more clear?

Thanks.

Regards
Senthil Kumar Sekar
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 507
    
    3
>1. Does this requires an internet connection?
On the face of it, this requires an internet connection. But you're using a framework that comes with its xml parser. If you use the xml parser that comes with hibernate, it would have EntityResolving mechanism built into it and it would use thereby a local copy of it in hibernate2.jar or hibernate3.jar versioning accordingly. If you use xml parser that comes with any other packages, in particular, such as from the jre, you would see the need clearer. And then, you can write your own resolver to redirect to the local copy for the purpose.

>2. Validating the xml blocks is not done in Hibernate ?
As said, and nothing to add.

If you put forward statements in general terms, be careful to spell out all the specificity, otherwise, you learn from the wrong experience and it is difficult to unlearn...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML and DTD