ved
ved

Reputation: 909

Exact dtd URI used in xml file for validation

I have query related to xml validation.When we write below code for xml validation

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

Here dtd file path is a exact URI , if we disconnect the internet , same validation again persist.I also thought that when we download the jars , may be dtd present in jar files.If present in jar files than why we write this kind of URI.

waiting for some solid reasons behind that..

Upvotes: 0

Views: 412

Answers (1)

C. M. Sperberg-McQueen
C. M. Sperberg-McQueen

Reputation: 25054

In many cases, URIs serve primarily the purpose of giving unique names to resources; like other mechanisms for assigning unique names, URIs achieve uniqueness through delegation: only the owner of domain www.hibernate.org can assign names in the URI space with that host name, and so their names will not conflict with the names of others (who will use URIs with different host names). Unlike many other mechanisms for assigning unique names, URIs have the advantage that they can in principle be dereferenced using simple widely available technology.

If software you are using is fetching the DTD from a JAR file and not by consulting the host named in the URI (it's plausible, but you don't say what software is involved and I don't make any claims one way or the other on the question), then it's not doing anything radically different from what any HTTP proxy does: using a local cached copy instead of fetching the same data again over the net.

The question "why do we write this kind of URI?" (instead of using some other identifier for the DTD) is most easily answered if you spend a little time thinking about alternatives to the use of URIs in system identifiers. It's easy to think of alternatives, but it's not only very hard to think of alternatives that are better than URIs, it's actually pretty hard to think of alternatives that aren't dramatically inferior to URIs. (At least, that's the inference I draw from the experience of the last twenty-five years in this area.)

Upvotes: 1

Related Questions