tags:

views:

619

answers:

3

First of all please don't close this question as duplicate of http://stackoverflow.com/questions/1181888/what-does-xmlns-in-xml-mean, Actually, i am having 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 everytime beanfactory creates the bean?

  • Is there any alternative so that i can use dwr, without hitting there 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"&gt;
+7  A: 

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".

Marc

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"&gt;   <==

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 in the site is down.

marc_s
*your code will still work even if the "www.directwebremoting.org" domain should be down or discontinued*, one thing for sure Marc, one hour back, directwebremoting was down and the beanfactory was unable to create bean [tried several times ], and then the site was back, and i didn't changed anything in my code, and it started working.. whats your take on this ?
Rakesh Juyal
+5  A: 

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 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.

Edit: (following complete header information)
Right, Rakesh, 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"&gt;

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.

mjv
Thank MJV, i will post the complete snippet... and what do u mean by Schema, is this DTD??
Rakesh Juyal
Wow, thanks MJV, last question. is it poosible to have this xsd in my system, and give the path like **c:/blahblah/dwr.xsd**. If possible, How to do this?
Rakesh Juyal
@Rakesh J : Yes, it is [possible to use a local path rather than an http-based URI], provided that wherever the application or XML processor etc. may be run from, it would have visibility and access to this path/file. It will work particularly well if you are exclusively running the application from your own machine, or if it run from machines which too have this file copied to their local drive at the same location (case of a published, non-online, application).
mjv
Many libraries store a copy of the XSD in the library jar itself and map the external URL in schemalocation to the file in the jar. So you might not have to download this XSD file. (just test first to see if this is what's happening)
wds
@wds: right! (I lost focus of what all the purpose of the XML was about, and was responding in the absolute) In the case of XML to support java libraries, the XSD is indeed often distributed along with the jar files.
mjv
@mjv **I lost focus of what all the purpose of the XML was about** :D, @wds: i dod have XSD file in dwr.jar, but does that mean i don't have to specify the schemaLocation ?
Rakesh Juyal
A: 

DTD can be a schema (also xdr and few more) The schema defains the structure of your input xml data (elements, attribute, attribute data type and so on)

IB