How to add xml schema attributes using JAXB?

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

    How to add xml schema attributes 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. For example:

    <User
    xmlns="http://testws/rest/schema"
    xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocat ion="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.
  • kokababu
    New Member
    • Jul 2008
    • 39

    #2
    Hmmm, I understood nobody knows answer of my question. However, I overcome the problem. I just take out the jaxb api and I have used StaX now. StaX is cool because it gives me to work low level task such I can now attache my multiple external schemes with the parser and writer. I have successfully achieved my goal using StaX.

    Comment

    Working...