For the following XML fragment:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
What do the xmlns
, xmlns:xsi
, and xsi:schemaLocation
attributes exactly mean? How are they related? What's the :
for?
And there are 2 URLs in the xsi:schemaLocation=
- http://maven.apache.org/POM/4.0.0 (it happens to be the same as
xmlns
but it gives a 404 error when visiting.) - http://maven.apache.org/xsd/maven-4.0.0.xsd (this is an actual XSD doc)
If 1 doesn't exist, why still put it there?
xmlns
is used to define the default namespace for the document. Any element in the document without explicit namespace prefix will be in the default namespace.xmlns:xxx
will define a non-default namespace, which must be explicitly prefixed to an element when using. Right? – Shwa