• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java 5 xml namespace problem

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
I am migrating a java application from java1.4 to java 1.5.0. The XML parser in Java is creating problems.
I am doing a transformation using the jaxp Transformer. From the DOMResult object, i am transferring the results using the importNode, appendNode methods.
In my XML i am using an attribute xml:space="preserve" in an element. I am getting NAMESPACE_ERR,because of this attribute. The lookupNamespaceURI method with prefix xml, brings null. My XML gets truncated after this xml:space="preserve" attribute.
How can I solve this issue?
If there is a problem with the java5 internal parser, is there a workaround?
Else how can I make java use an external parser?
Thanks in advance for any probable solution or comments?
Have a nice day!
Regards,
Subha.
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Suba,
I am not sure how to fix your problem but I am having a problem with java 1.4 version and hoping you could throw some pointers.

I have to use JDK 1.4 version (Since I am using weblogic 8.1 in my environment) and I am trying to do JAXB stuff. on the website I tried downloading JAXB 2.0 and it seems it works only with java 1.5 version only and I tried all other versions but I am not able to get a proper version to work with java 1.4.

How do you manage to work on JAXB with java 1.4 version? if you have that JAXB download with you can you send me as a zip(I can give my email addr if you want to send as a attachment)? or give me link that I can get. I tried JAXB 1.0.5, JAXB 1.0.4 and 1.0.6 versions from Sun website but some reason, none of them working with my version or they are missing jaxb-api.jar ...

I need to figure this soon. Any help from anyone on this would be greatly appreciated.

Thanks,
Ugender
 
Ugender Rekulampally
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK... I figured it out. I downloaded jwsdp-1.5 and it has the JAXB libs for jdk 1.4.

I was looking for JAXB package alone on the SUN website. I didnt know JAXB comes with jwsdp package in previous versions.

Thanks,
Ugender
[ May 20, 2007: Message edited by: Ugender Rekulampally ]
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ugender, please don't hijack other people's threads like that. Start a new thread if you have a question in future.

Subathra, I looked in the XML recommendation and it says this about the xml:space attribute:

In valid documents, this attribute, like any other, MUST be declared if it is used.

And I expect your transformed document does not contain a DTD that declares the attribute. Probably the old parser was careless and didn't enforce this rule, and the new parser is working correctly.

What I might suggest is this: the xml:space attribute is there to control which whitespace is significant in the document, right? So why not just create the document so that it contains only significant whitespace, and leave off the xml:space attribute?
 
subathra sangameswaran
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
Thanks Paul for your reply.
The problem is that i am not the owner of the XML file.
The xml files are created by the customers of our application.
What about the XML files that are existing and running since inception.
I cannot change all this data.
The attribute is declared in the DTD. I am actually doing two transformations.The first time i am not getting any errors. The transformed Document object, i am transforming again, and this time the problem arises.
I do not totally understand why the problem does not arise the first time time and but only the second time.
The xsl looks alike, the DocumentBuilderFactory,DocumentBuilder,Transformer etc. object creation code are identical.
Have a nice day!
Regards
Subha.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by subathra sangameswaran:
I am actually doing two transformations. The first time i am not getting any errors. The transformed Document object, i am transforming again, and this time the problem arises. I do not totally understand why the problem does not arise the first time time and but only the second time.

The incoming document had a DTD. It was valid. When you transformed that into another document, that other document did not have a DTD. (I assume you did not specify one in your transformation.) Then when you tried to parse that other document, the one that included an xml:space element but no DTD, the exception occurred. That is because your first transformation produced a document that was not valid.
 
subathra sangameswaran
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,
Thank you. You are correct. After the hint you gave yesterday,i am trying to get the doctype declaration in the result of the first transformation, so that the second transformation is successful. I tried adding both in my first xsl and in the second xsl <xsl:output doctype-system="/tmp/TestSuite.dtd"/>. I tried transformer.setOutputProperty("doctype-system","/tmp/TestSuite.dtd"). But i cannot get the doctype declaration in the result of the first transformation. When i use org.apache.xalan.xslt.Process, i get the Doctype declaration in the resultant transformation. But not using jaxp transformer. What can be done? Where do I err? Thanks again! Regards, Subha.
 
subathra sangameswaran
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
I used an external apache parser using the following system properties and the problem is solved.
-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
-Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl\

Apart from that i did
DocuementBuilderFactory.setNamespaceAware(true)

Thanks and have a nice weekend!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic