This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Facing problem with JAXB1.0  RSS feed

 
yogesh chaudhari
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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.

schema detail is as below..

<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.abcd.com/AtASchema" targetNamespace="http://www.abcd.com/AtASchema" elementFormDefault="qualified" version="1.0">
.......

and corresponding xml in DOM is...

<?xml version="1.0" encoding="UTF-8"?>
<PartnerPartyProfile AttributeStatus="Cached" xmlns="http://www.abcd.com/AtASchema"><PartnerBeGeo>......
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
yogesh chaudhari
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. we are creating attribute in DOM object the code is as below

NodeList childNodes=docResult.getChildNodes();

Element profileElement=(Element)childNodes.item(0);

//profileElement.setAttribute("AttributeStatus", status);

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

<ns1:CommerceProfile ns1:AttributeStatus='Cached' xmlns:ns1='http://www.abcd.com/AtASchema'>
<ns1:AccessAndApproval>
<ns1:IPCAccess>
12
</ns1:IPCAccess>..... ...

Why its displaying prefix ns1 .
The desired output XML should be like this..

<CommerceProfile AttributeStatus='Cached' >
<AccessAndApproval>
<IPCAccess>
12
</IPCAccess>
 
yogesh chaudhari
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I missed something in desired XML output. The desired output is as below

<CommerceProfile AttributeStatus='Cached' xmlns="http://www.abcd.com/AtASchema">
<AccessAndApproval>
<IPCAccess>
12
</IPCAccess>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!