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)
[ August 08, 2006: Message edited by: Todd Johnson ]
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.
Joined: Sep 03, 2005
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.