| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE html | |
| PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| <html> | |
| <head> | |
| <!-- /******************************************************************************* | |
| * Copyright (c) 2000, 2005 IBM Corporation and others. | |
| * All rights reserved. This program and the accompanying materials | |
| * are made available under the terms of the Eclipse Public License v1.0 | |
| * which accompanies this distribution, and is available at | |
| * http://www.eclipse.org/legal/epl-v10.html | |
| * | |
| * Contributors: | |
| * IBM Corporation - initial API and implementation | |
| *******************************************************************************/ --> | |
| <link rel="stylesheet" type="text/css" href="../../org.eclipse.wst.doc.user/common.css" /> | |
| <title>Generate an XML file from a DTD</title> | |
| </head> | |
| <body id="tcrexdtd"><a name="tcrexdtd"><!-- --></a> | |
| <h1 class="topictitle1">Generating XML files from DTDs</h1> | |
| <div><p>You can generate an XML file from your DTD if you want to quickly | |
| create an XML file based on your DTD file. Generating an XML file from your | |
| DTD saves you time by creating an XML file that is already associated with | |
| your DTD, and contains at least some of the elements and attributes in your | |
| DTD.</p> | |
| <div class="section"><p>After you have generated your XML file, you can further customize | |
| it in the XML editor.</p> | |
| <p>The following instructions were written for the Resource | |
| perspective, but they will also work in many other perspectives.</p> | |
| <p>To | |
| create an XML file from a DTD file follow these steps:</p> | |
| </div> | |
| <ol><li class="skipspace"><span>In the Navigator view, right-click the DTD file that you want to | |
| work with.</span></li> | |
| <li class="skipspace"><span>From its pop-up menu click <b> <span class="menucascade"><span class="uicontrol">Generate</span> > <span class="uicontrol">XML File</span></span></b>.</span></li> | |
| <li class="skipspace"><span>Select a project or folder to contain the XML file and type a name | |
| for it.</span> The name of the file must end in <kbd class="userinput">.xml</kbd>.</li> | |
| <li class="skipspace"><span>Click <b> <span class="uicontrol">Next</span></b>.</span></li> | |
| <li class="skipspace"><span>Select the <b> <span class="uicontrol">Root element</span> | |
| </b>of the XML file.</span> The root element of an XML file is the element that contains all other | |
| elements in that file. All the elements that you have defined in the DTD will | |
| be shown in the<span class="uicontrol">Root element</span> list.</li> | |
| <li class="skipspace"><span>Select from the following content options: </span><ul><li> | |
| <b><span class="uicontrol">Create optional attributes</span> </b>- Both | |
| mandatory and optional attributes will be generated.</li> | |
| <li><b><span class="uicontrol">Create optional elements</span> </b>- Both | |
| mandatory and optional elements will be generated.</li> | |
| <li><b><span class="uicontrol">Create first choice of required choice</span></b> - | |
| The first choice of a required choice will be generated in your XML file.</li> | |
| <li><b><span class="uicontrol">Fill elements and attributes with data</span></b> - any | |
| elements and attributes generated will be filled with sample data.</li> | |
| </ul> | |
| <p>If you do not select any of these options, then only the minimum | |
| amount of content required for the XML file will be created.</p> | |
| </li> | |
| <li class="skipspace"><span>Specify the <b> <span class="uicontrol">Public ID</span></b> or | |
| <b> <span class="uicontrol">System | |
| ID</span>.</b></span> You do not need to specify both. If you do, the Public ID will | |
| be used before the System ID. </li> | |
| <li class="skipspace"><span>Click <b> <span class="uicontrol">Finish</span></b>.</span></li> | |
| </ol> | |
| <div class="skipspace"> | |
| <p>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 that you used to create the XML file.</p> | |
| </div> | |
| </div> | |
| <div><p><b class="relconceptshd">Related concepts</b><br /> | |
| <a href="../topics/cwxmledt.html" title="The XML editor is a tool for creating and viewing XML files">XML editor</a><br /> | |
| </p> | |
| <p><b class="reltaskshd">Related tasks</b><br /> | |
| <a href="../topics/tcretxml.html" title="You can create a new empty XML file, which you can then edit in the XML editor.">Creating an XML file from scratch</a><br /> | |
| <a href="../topics/tcrexxsd.html" title="Generating an XML file from an XML schema">Generating an XML file from an XML schema</a><br /> | |
| <a href="../topics/txedttag.html" title="Editing XML files">Editing XML files</a><br /> | |
| </p> | |
| </div> | |
| </body> | |
| </html> |