Generating XML schema files from XML files

If you have an XML file that does not have an XML schema, you can use your XML file to create an XML schema for it. Generating an XML schema from your XML file saves you time by creating an XML schema that will work with your XML file, and contains all of the elements that were in your XML file.

The XML file must be well-formed, otherwise, when you try to create the schema, you will receive an error message and the schema will not be created. For an XML file to be well-formed, it has to follow certain specifications set out in the XML 1.0 recommendation.

The following instructions were written for the Resource perspective, but they will also work in many other perspectives.

To create an XML schema from an XML file, follow these steps:

  1. Create a project to contain the XML schema file. If you intend to generate Java™ beans from your XML schema, we recommend you create a project that is configured to work with Java source to contain both the XML schema and the beans (the beans must be contained in a project configured to work with Java source, however, the XML schema does not have to be). Otherwise, it does not matter what kind of project you create.
  2. Select the XML file you want to create the XML schema from. Right-click it and click Generate > XML Schema.
  3. Select the folder or project that will contain the schema. In the File name field, type the name of the schema, for example MyXMLXSD.xsd. You must end the name of your schema with .xsd.
  4. Click Finish.
  5. A dialog box opens, indicating that the XML schema has been successfully generated.

The schema opens automatically in the XML schema editor. It will contain all the elements that were in the XML file you used to create the schema. You can now customize it further, adding new elements and so on.

Related tasks
Creating XML schemas
Generating XML schema files from relational tables
Generating Java beans from an XML schema
Generating HTML documentation from an XML schema file
Related information
XML 1.0 on the W3C
Editing XML schema properties
XML schema editor
Validating XML schemas
Generating XML schemas from DTD files

Feedback