In many xml examples i see many nameschemas which even dont use in xml like in below example we have defined nameschemas as xsi,aop and one default
namespace. If we dont use them what the purpose of defining them.Did not attach the xml as its quite big.
Second question is :- Assume that we using this nameschemas..We usually defined the values of namechemas and schemalocation with some web address
like http://someAdddress//. What if we define them with some arbitrary value like ABC or something else. Will it make any differnce? Is there any
processing we do from these web addresses?
As for your questions about namespaces, here's a link to a Namespaces tutorial. At least one of your questions is an FAQ which is explicitly answered there.
As for your last question, although I don't know much about XML Schema, it seems to me that it makes sense to specify the schema location for something which represents a schema, whereas specifying the schema location for something which doesn't represent a schema doesn't make sense. At least to me.
Q1. >...If we dont use them what the purpose of defining them... If the xml document eventually does not use some of them, those unused namespaces are actually serving no purpose being there. However, they do no harm to the semantic neither. Hence, you can tolerate them being there. Sometimes, the application generating the documents may pick up data from numerous sources, using xslt here or there..., and eventually some data from certain namespaces do not turn up in the final document. Chances are their namespace nonetheless being set up after all because the xslt or whatever stand in the middle are coded with some generality in mind... In any case, they do no harm to the semantic of the final document and if you don't like them you can safely disregard them.
Q2. >...What if we define them with some arbitrary value like ABC or something else. Will it make any differnce? Is there any
processing we do from these web addresses? ... In the case of the document being parsed by non-validating parser, it will be making not much difference as long as the names of the namespaces are still not colliding each other or some additional namespaces you want to check against as well. Those namespace names, as long as being in the uri syntax in general, they are just fine --- again as long as the non-validating parser is concerned. And in that case, nothing "physical" like fetching something from the "web address" or else is actually happening. But, if the document is being parsed by the validating parser, then, those names pick up real meaning because the name must be validated against the corresponding schema(s)... That is about the idea in the big picture.
Q3. >...we have defined the schemalocation for xsi namespace only Not for aop namespace.Why so? It reflects only that your reading of the line:
>xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/ schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aophttp://www.springframework.org/schema /aop/spring-aop-2.0.xsd" in actually incorrect.
The line actually means you suggest the schema locations for the namespaces of the default and of the prefix aop. It does not define any location for xsi at all, quite the contrary. (You have to read the documentation on the schemaLocation attribute which belongs to the namespace having the prefix xsi, ie the XMLSchema-instance.)
However, that piece of information is only suggestive and the schema locations used in the application take precedence over them. But, if the application itself does not furnish their schema locations, validating parser would attempt to use that piece of information for the validation purpose... That's the general picture. Things may get quite involved no doubt and can't be oversimplied too much. Again you have to rely on the documentation for the exact mechanism if you intend to put thing into practice.