Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
stephen_xue
Active Participant
0 Kudos
If you are totally new to JAXB, please refer to https://blogs.sap.com/2019/11/06/jaxb-in-sap-pi-java-mapping/

1         XSD has “import”, “include”


Difference



  • Import has to be from another namespace;

  • Include has the same namespace;


Symptom


When XSD file, like common, has types as below:



Get error like below in the console while generating classes from XSD by using JAXB


Solution


Place all of the relevant xsd files into one folder

Please get all of the sample XSD files from Github and load them into eclipse. (this is my first time use Github. if you have difficult download the files, please let me know)

Here is the view from the eclipse



Create the class from schema by using the usual way



Get these logs in the console



All of the relevant classes will be listed below


2. Create class from simple type


By default, the JAXB will only generate class from complex types of the schema. If the simple types are intended to be converted into class, a special binding file has to been created.
<bindings version="2.0" xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:annox="http://annox.dev.java.net">
<bindings>
<globalBindings mapSimpleTypeDef="true"/>
</bindings>
</bindings>

copy paste the above code and create a file with name: bingdings.xjb

It can be downloaded from Github as well.

Place the file in the package folder



Generate class from schema as below



In the step below, choose the xjb from the folder



This is the view after clicking OK button



By clicking the Finish button, all of the types will be created into java classes

Compare with the list in the last section, we can see there are more classes generated. Actually all classes have been generated from both complex types and simple types in the schema.



 
Labels in this area