Search Results

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.