File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Missing Namespace URIs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Missing Namespace URIs" Watch "Missing Namespace URIs" New topic

Missing Namespace URIs

Todd Johnson
Ranch Hand

Joined: Sep 03, 2005
Posts: 61
I'm new to XML parsing. I'm having a problem where I ouput a DOM document using an identity transformer and for some reason the namespace URI's are missing.

I'm using Java 1.4.1_03. If I add the jars from the latest version of xalan to the classpath, I get my URIs. The problem is that because this is going onto a webserver running a lot of legacy code, they will not allow me to load xalan (and the latest xercesImpl.jar, etc) because of the risk of impacting the existing applications.

I figure there is some feature I have to set, or something else small I'm missing to get the transformer to output the namespace URIs.

I wrote a little test program to demonstrate the problem (see the end of the post). Below is the output from two runs of that test program. The first is with the xalan jars in the classpath. The second is without the xalan jars in the classpath. Notice the namespace URIs disappear. Is there someway, without using the xalan package, I can get the transformer to output the namespace URIs?

With xalan (namespace URIs are present)

Without xalan (namespace URIs are missing)

Test program

[ August 08, 2006: Message edited by: Todd Johnson ]
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

I'm sorry to tell you that I had a look through the Java bug database (because leaving off namespace declarations is clearly a bug) and I found this bug report. In which it says
For JDK 1.4, using JAXP identity transforms for namespaced documents is too buggy to consider...
I can't fault your webserver admins for not letting you install your own version of Xalan et al., that sort of thing can easily screw up the workings of the app server. (I've seen it happen in my own setup.) But perhaps if XML serialization is all you need, and not XSLT transformation, you could hunt down some Java code that just serializes a DOM and install that with your app.
Todd Johnson
Ranch Hand

Joined: Sep 03, 2005
Posts: 61

Thanks for the quick reply! Wow! I can't believe it's that broken in 1.4. I don't understand why no one else seems to be complaining as I didn't find much on the net when I searched for this. I guess not many people using 1.4 are using the identity transform to output XML files with namespaces.
I agree. Here's the link:
subject: Missing Namespace URIs
It's not a secret anymore!