It looks the JAXB2 using XSOM to mapping the xml schema. So is it possible to mapping XML schema to JAXB2 POJO?
Yes, you can.
The problem is that the generated POJOs aren't very usable. For example, every reference is just a QName, so it's still up to application code to resolve them. Or, the notion of schema components aren't obvious in the schema4schema, so again it's up to application code to figure those things out.
For these reasosn, XSOM gives you better OM than XJC does (which isn't too surprising --- if a compiler can produce a better code than a human does, then there'd be no jobs left for us humans!) The downside of course is that it takes more time to write code manually.
Rewriting XSOM to use JAXB behind the scene to parse XML would be an interesting exercise. It should be possible, and if someone is interested in doing so, s/he is more than welcome!
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.