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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kokababu
    New Member
    • Jul 2008
    • 39

    #1

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

    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
    Code:
    <User 
        xmlns="http://testws/rest/schema"		
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://testws/rest/user UserSchema.xsd">
    
    </User>
    How do I add xmlns, xmlns:xsi, xsi:schemaLocat ion 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.
Working...