Generating XML files from DTDs

U kunt een XML-bestand aan de hand van een DTD-bestand genereren als u een XML-bestand snel op basis van het DTD-bestand wilt maken. Dit levert een tijdwinst op, doordat het XML-bestand al aan het DTD-bestand is gekoppeld en ten minste enkele van de elementen en kenmerken uit het DTD-bestand bevat.

After you have generated your XML file, you can further customize it in the XML editor.

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

Ga als volgt te werk om een XML-bestand te maken op basis van een DTD-bestand:

  1. In the Navigator view, right-click the DTD file that you want to work with and select Generate > XML File.
  2. Select a project or folder to contain the XML file and type a name for the file in the File Name field, then click Next. The name of the file must end in .xml.
  3. Select the Root element of the XML file. Dit is het element dat alle andere elementen in het XML-bestand bevat. All the elements that you have defined in the DTD will be shown in the Root element list.
  4. Select from the following content options:
    • Create optional attributes: both mandatory and optional attributes will be generated.
    • Create optional elements: both mandatory and optional elements will be generated.
    • Create first choice of required choice: the first option of a required choice will be generated in your XML file.
    • Fill elements and attributes with data: any elements and attributes generated will be filled with sample data.
    Als u geen van deze opties selecteert, wordt slechts de minimale hoeveelheid content voor het XML-bestand gemaakt.
  5. Specify the Public ID or System ID. U hoeft niet beide ID's op te geven. Anders krijgt het openbare ID voorrang.
  6. Klik op Voltooien.

Het XML-bestand bevat alleen het geselecteerde hoofdelement en alle elementen of kenmerken van het hoofdelement. U kunt nu elementen, kenmerken, entiteiten en notaties aan het XML-bestand toevoegen. Houd wel rekening met de regels in het DTD-bestand aan de hand waarvan u het XML-bestand hebt gemaakt.

Verwante concepten
XML editor
Verwante taken
Creating XML files
Generating XML files from XML schemas
Editing XML files