| <?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>Generating XML schemas from DTD files</title> |
| </head> |
| <body id="tgenxmls"><a name="tgenxmls"><!-- --></a> |
| |
| <h1 class="topictitle1">Generating XML schemas from DTD files</h1> |
| <div><p>Generating an XML schema from a DTD file enables you to create |
| an XML schema that is automatically populated with elements and attributes |
| from your DTD file. This can save you time if you want to use an XML schema |
| rather than a DTD file to validate your XML file, but you want to use the |
| rules already set up in your DTD file.</p><div class="skipspace"><p>The following instructions were written for the Resource perspective, |
| but they will also work in many other perspectives. </p> |
| <p>To generate |
| an XML schema file from a DTD file, follow these steps:</p> |
| </div> |
| <ol><li><span>In the Navigator view, right-click your DTD and click <span class="menucascade"><span class="uicontrol">Generate</span> > <span class="uicontrol"> XML Schema</span></span>.</span></li> |
| <li><span>Select the project or folder that will contain the schema. </span></li> |
| <li><span>Accept the default name or type a new one and click <span class="uicontrol">Next</span>.</span></li> |
| <li><span>If you want to create an XML schema that will contain your DTD |
| file and any DTD files it references, click the <span class="uicontrol">Create one XML |
| schema that includes all the DTD files</span> radio button.</span></li> |
| <li><span>Otherwise, if you want to create an individual schema for your |
| DTD file and each DTD file it references, click the <span class="uicontrol">Create an XML |
| schema for each DTD file</span> radio button.</span></li> |
| <li><span>Click <span class="uicontrol">Finish</span>.</span></li> |
| </ol> |
| <div class="skipspace"><p>Your schemas appears in the Navigator view. They will have the |
| same name as the DTD file they were generated from (if you accepted the default |
| value in the <span class="uicontrol">File name</span> field when you generated the |
| XML schema). </p> |
| <p>Any entities that were in your DTD file will not be in |
| the XML schema (as entities are not supported in XML schemas). However, |
| any elements or attributes that referred to an entity will carry over that |
| value to an XML schema.</p> |
| </div> |
| <div class="skipspace"><p>For example, you have a DTD called "Legal" that contains an entity |
| called "Copyright". The value of the entity is "Copyright 2004. MyCompany |
| Publishing" . In your DTD, you have an element called "MyCopyright", which |
| refers to the entity Copyright. After you create the XML schema, the Copyright |
| entity will not appear in the XML schema, however, its value is carried over |
| (that is, MyCopyright will have the value: Copyright 2004. MyCompany Publishing |
| ).</p> |
| <p>All elements and attributes that existed in your DTD file will exist |
| in the XML schema file.</p> |
| <p>Elements in your DTD with a content model of |
| (#PCDATA) (and no attributes) appear empty in the XML schema editor. They |
| are marked as having <span class="uicontrol">Built-in simple types</span> of <samp class="codeph">string</samp>. |
| That is, a DTD element with a value of (#PCDATA) will map to an XML schema |
| element with an XML schema primitive type <samp class="codeph">string</samp>.</p> |
| <div class="note"><span class="notetitle">Note: </span>When |
| you generate an XML schema from a DTD file that contains Hebrew or Arabic |
| elements, certain element names might be encoded with their equivalent hexadecimal |
| Hebrew and Arabic encoding values. To avoid this problem, change the encoding |
| attribute of the original DTD or XML schema file to UTF-8 before performing |
| the generation: That is, the XML declaration should be: <samp class="codeph"><?xml |
| version="1.0" encoding="UTF-8"?></samp> The list of affected encoding values |
| is: ISO-8859-8-I, ISO-8859-8, Windows-1256, and ISO-8859-6.</div> |
| </div> |
| </div> |
| |
| <p><b class="reltaskshd">Related tasks</b><br /> |
| <a href="../topics/tcretdtd.html" title="A document type definition (DTD) contains a set of rules that can be used to validate an XML file. After you have created a DTD, you can edit it, adding declarations that define elements, attributes, entities, and notations, and how they can be used for any XML files that reference the DTD file.">Creating DTDs</a><br /> |
| </p> |
| <b>Related information</b><br /><a href="../../org.eclipse.wst.xsdeditor.doc.user/topics/tedtschm.html">Editing XML schemas</a><br /> |
| </body> |
| </html> |