I have come across many xml configurations in struts , spring , ibatis etc. i used to use the declaration blindly coz im ignorant. I really want to know how this declarations are useful, is the one use being confirming to the DTD ?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
If you mean:
xmlns="http://www.springframework.org/schema/beans"andxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"this are name spaces.
the line
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">is about where the name space declaration can be found.From the comments:
Assume you have two different XSD schemata that you want to use both in your XML. And both of them define a tag with the same name, but different meaning. Then an program that read your XML file need to understand which of the both tags you mean. So that is what the prefix (
xsi) or what ever is used for.The complete thing is used for validation, and editor support (auto completion). But also for stuff that is proceeding the XML without knowledge about the concrete semantics. (XLST for example.)