By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,433 Members | 776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,433 IT Pros & Developers. It's quick & easy.

How to add xml schema attributes into the java object using JAXB?

P: 39
Hi,

I have to add xml schema attributes into the java object.
Such as, my java object is User. This User object will be
represented as XML using JAXB. I generated XML
from User object successfully using JAXB. But I want to add xml schema attributes such as
Expand|Select|Wrap|Line Numbers
  1. <User 
  2.     xmlns="http://testws/rest/schema"        
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  4.     xsi:schemaLocation="http://testws/rest/user UserSchema.xsd">
  5.  
  6. </User>
How do I add xmlns, xmlns:xsi, xsi:schemaLocation attributes in the User (root) element, using JAXB?
I tried with @xmlSchema annotation but it threw the following error:
Package annotations must be in file package-info.java

I would be grateful, if someone help me to solve this issue.
Jul 20 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.