Converting JAVA Class to XML Schema

This topic lists the rules that need to be followed when converting Java class to XML schema.

The Java class is converted to an XML schema using the following rules:
  • The Java class public member should not have the public getter and setter methods for it.
  • The Java class member public variable name is mapped to an XML element with the same name. For example, a Java class member variable declared as public int ZipCode is mapped to an XML element named ZipCode.
  • The Java Bean accessors and modifiers are mapped to appropriate XML element names. For example, a Java class method public int getBalance() or public void setBalance(int Balance) are mapped to an XML element named Balance.
  • Only one XML element is created regardless of how many members of the Java class share the same name. For example, there may be an attribute named MySalary and accessors named getMySalary() and setMySalary(). This translates to one element named MySalary in the resulting XML document.
  • All Java primitive types are supported. Datatypes that extend java.util.Collections, are also supported (for example, List, ArrayList, and Vectors). Arrays (for example, int[ ] and string[ ]) are also supported.
  • Use Java generics and provide the type information while declaring and creating the collection for example,

    Instead of using List list = new ArrayList();

    use generics: List<String> list = new ArrayList<String>();

  • The datatype java.util.Map or any types that extend java.util.Map are not supported. For example, HashMap is not supported.
  • The variable name defined in the class should be exactly same as the getter and setter methods defined for the same variable. Otherwise, there can be a schema generation issue by JavaToXML and XMLToJava activities. For example, if a variable name is airfileRouteStartTime, names of the getter and setter methods must be getAirfileRouteStartTime(), and setAirfileRouteStartTime() respectively.
  • Class should implement java.io.Serializable interface.
  • The boolean variable names defined should not start with the keyword is. For example, "isemployee ". It conflicts with the getter and setter methods isemployee() and setemployee() and results in the schema generation issue.