Creating an XML file from DTD or XML Schema


Generating an XML file from a DTD or XML Schema can be useful if you want to quickly create an XML file that is based on your gramma file.

To create an XML file from a gramma file follow these steps:

  1. Invoke New XML File wizard using workbench menu File>New>Other>XML>XML.
  2. On the first page select depending on what type of gramma file you need choose Create XML file from DTD file or Create XML file from an XML Schema file radio button.
  3. On XML File Name page select a project or folder to contain the XML file and type a name for it. The name of the file must end in *.xml.
  4. The next choice you have to do is to select your gramma file. You can select it from the workspace (you can import files into the workspace if they are not there) Another possibility is to use DTD and XML files defined in XML Catalog .
  5. On the Select Root Element page select from the following content options:

    If you do not select any of these options, then only the minimum amount of content required for the XML file will be created.

  6. The last this is to specify document type (Figure 1) for DTD or namespace (Figure 2) for XML Schema information.

    For DTD:

    For XML Schema:

Figure 1: Selecting Root Element page based on DTD file:

Figure 2: Selecting Root Element page based on XML Schema file:

When wizard finished the XML file will only contain the selected root element and any elements or attributes contained in the root element. You can now add elements, attributes, entities, and notations to the XML file, however, they must follow the rules established in the DTD or XML Schema file that you used to create the XML file.