This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
In our project we are using JAXB1.0. I have a DOM object. and I want to set the value of an attribute. After setting attribute value, when I print DOM object it correctly shows that attribute. But on client side after unmarshalling it returns the attribute value as null.
XSD uses namespace & same namespace URL is showing in XML document.
Did you create the attribute in your DOM with no namespace, or with the default namespace? I'm sure DOM will allow you to do the latter, but you shouldn't because unprefixed attributes are always in no namespace and not in the default namespace.
Joined: Dec 16, 2008
Thanks for the reply. we are creating attribute in DOM object the code is as below
profileElement.setAttributeNS("http://www.abcd.com/AtASchema","AttributeStatus", status); profileElement.setPrefix(""); ............................................................ when I used setAttributeNS method and mention namespace in that it gives the desired output but 'ns1' as a prefix for every element. XML output after unmarshalling for the same is as below