Generating XML schema from Java classes


XML & Web services: Generating XML schema from Java classes

  1. I have a set of Java classes and would like to generate an XML schema from it. Is there a tool that can do it? I'm aware of several tools that generate java classes from XML schema (xmlbeans, jaxb etc.), but dont know of any that creates an xml schema from java classes.

    One solution is to generate an 'xml instance' from objects of the java classes using a tool that doesnt need any mapping file (such as XStream, and then create an XML schema from the XML instance using Castor or XMLBeans. However, this approach is not ideal because the type information in the java classes is lost when the java objects are converted to an XML instance.

    Any other ideas?


    Threaded Messages (4)

  2. I finally figured out another solution and thought it would be useful to post it here to those who are curious. JAXB 2.0 can create XML Schemas from Java classes and uses annotations in JDK 1.5 to customize the creation of schemas. JAXB 2.0 is not a official release yet, but there is an early RI of it available at

    - Srinivas
  3. Java2Schema tool[ Go to top ]

    The serializer/deserializer uses class descriptions based on XML Schema. As we shall see, these schema descriptions can be generated with the Java2Schema tool available with WASP Server for Java. The Java2WSDL tool can also be used, in which case the generated schema will be embedded in the Types section of the WSDL definition. For more information on working with XML Schema, the Zvon website provides an excellent reference source .
  4. You mention I looked at the "unoffical user's guide" on this site. It talked about annotations in Java code but did not talk about what command to use for generating Java from an XML schema. Could you give a more specific pointer to the documenation on how to do this ? Thanks.
  5. xfire[ Go to top ]

    i have write web services project with xfire, it's very nice java web services framework, just create an interface class and xfire will create its wsdl automatically, for information about this just see: