Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is xmlns in this particular XML file?

I have an entry in my servlet.xml,

xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr

Now, what I think is, dwr is the prefix we are going to use, like

<dwr:configuration>
    <dwr:convert type="bean" class="com.abc.bean.MyBean" />
</dwr:configuration>

Now the problem is, if the site http://www.directwebremoting.org is down then my application is unable to create the beans.

  • Is it going to hit this website every time beanfactory creates the bean?

  • Is there any alternative so that I can use dwr, without hitting their website?


Complete header:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
       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 
       http://www.springframework.org/schema/aop 
       http://www.springframework.org/schema/aop/spring-aop-2.0.xsd 
       http://www.directwebremoting.org/schema/spring-dwr 
       http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd"> 
like image 940
Rakesh Juyal Avatar asked Oct 12 '09 06:10

Rakesh Juyal


2 Answers

It's an XML namespace. This is used to make sure your XML identifiers (tags, etc.) are unique - you just wrap them in a namespace (like a .NET namespace).

The namespace is just an identifier - it is NOT a real location on the web!

The XML namespace needs to be unique - that's why lots of companies use their *.com domain name in the namespace since no one else can (or should) be using that.

But the "pseudo-URL" you have there is NOT a physical URL, and your code will still work even if the "www.directwebremoting.org" domain should be down or discontinued!

It's just a name - nothing but a name - no physical file resides behind that "URL".

UPDATE: Okay, we have a different issue here:

<beans xmlns="http://www.springframework.org/schema/beans"
       ...........
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-2.0.xsd  
       http://www.springframework.org/schema/aop 
       http://www.springframework.org/schema/aop/spring-aop-2.0.xsd   
       http://www.directwebremoting.org/schema/spring-dwr 
     ==>  http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">   <==

These xsi:schemaLocation entries are the culprit - these of course cause a dependency on that site being up, since you're referencing a XML schema file (spring-dwr-2.0.xsd) directly via a URL on that site.

You could definitely also download those *.xsd files to your local disk and use it from there. The XML namespace as such is nothing but a name, but this schemaLocation, http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd, obviously is a real, physical URL and won't work if the site is down.

like image 141
marc_s Avatar answered Sep 25 '22 13:09

marc_s


The problem is probably not directly related to the namespace per se, but to the schema location of this dwr namespace.

Whereby the URI used as the namespace identifier can be "anything" and is not accessed to process the file (we use Internet domain based namespaces IDs as a convenient way to have globally unique namespaces), the schema location is effectively accessed.

To fix the problem, you may be able to download the schema, publish it on a reliable site, and alter the schema location in the XML files which reference it.

The "schema" is the DTD, or more typically nowadays, as is the case here an XSD file. In practical terms, you need to download the following.

  http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd

You can then publish the spring-dwr-2.0.xsd on an server of your own (or you can make it available in a directory, if these are not online applications), and change the corresponding line in the XML header to read (where MyOwnDomain, etc. reflects your actual site of course):

   http://www.directwebremoting.org/schema/spring-dwr 
   http://www.MyOwnDomain.com/SomeDirectory/spring-dwr-2.0.xsd">

In that fashion, even when the directwebremoting.org site is not available, there will be no delays in your XML processing logic.

Attention, it is quite possible that the XSD in question makes reference to other schemas, and if that were the case you'd also want to download these and ensure the XSD points to the new location as well for these.

like image 32
mjv Avatar answered Sep 25 '22 13:09

mjv