syeshin | befd53e | 2005-07-27 18:16:40 +0000 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <!DOCTYPE html |
| 3 | PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 4 | <html> |
| 5 | <head> |
syeshin | aaa2193 | 2005-09-22 17:13:22 +0000 | [diff] [blame] | 6 | <!-- /******************************************************************************* |
| 7 | * Copyright (c) 2000, 2005 IBM Corporation and others. |
| 8 | * All rights reserved. This program and the accompanying materials |
| 9 | * are made available under the terms of the Eclipse Public License v1.0 |
| 10 | * which accompanies this distribution, and is available at |
| 11 | * http://www.eclipse.org/legal/epl-v10.html |
| 12 | * |
| 13 | * Contributors: |
| 14 | * IBM Corporation - initial API and implementation |
| 15 | *******************************************************************************/ --> |
| 16 | <link rel="stylesheet" type="text/css" href="../../org.eclipse.wst.doc.user/common.css" /> |
syeshin | befd53e | 2005-07-27 18:16:40 +0000 | [diff] [blame] | 17 | <title>Editing with DTD or XML schema constraints</title> |
syeshin | 6607827 | 2005-09-20 16:53:38 +0000 | [diff] [blame] | 18 | </head> |
syeshin | befd53e | 2005-07-27 18:16:40 +0000 | [diff] [blame] | 19 | <body id="tedtcnst"><a name="tedtcnst"><!-- --></a> |
| 20 | |
| 21 | <h1 class="topictitle1">Editing with DTD or XML schema constraints</h1> |
| 22 | <div><p>In the Design view, when you edit an XML file that has a set of |
| 23 | constraints (that is, a set of rules) defined by a DTD or an XML schema, you |
| 24 | can turn the constraints on and off to provide flexibility in the way you |
| 25 | edit, but still maintain the validity of the document periodically.</p><div class="skipspace"><p> When the constraints are turned on, and you are working in the |
| 26 | Design view, the XML editor prevents you from inserting elements, attributes, |
| 27 | or attribute values not permitted by the rules of the XML schema or DTD, and |
| 28 | from removing necessary or predefined sets of tags and values. In this mode, |
| 29 | an element's content must be valid to use the XML editor's guided editing |
| 30 | options.</p> |
| 31 | <p>You may want to turn the constraints off for an XML file if |
| 32 | you need more flexibility. For example, you want to try working with elements |
| 33 | or attributes not permitted by the associated DTD or XML schema, without actually |
| 34 | removing the association with the DTD or XML schema.</p> |
| 35 | <p>To turn the constraints |
| 36 | for an XML file off, click <span class="uicontrol">XML > Turn Grammar Constraints Off</span>. |
| 37 | After you have turned the constraints off for a file, you can insert or delete |
| 38 | any element or attribute regardless of the DTD or XML schema rules. You can |
| 39 | create new elements or attributes that are not in the DTD or schema - these |
| 40 | Design view prompts will only appear when you have turned constraints off. |
| 41 | The file may not be valid, however, if you do this. </p> |
| 42 | <p>The following instructions |
| 43 | were written for the Resource perspective, but they will also work in many |
| 44 | other perspectives.</p> |
| 45 | <p>The following is an example of what you can do if |
| 46 | you turn the constraints of a DTD off:</p> |
| 47 | </div> |
| 48 | <ol><li class="skipspace"><span>Open the XML file in the XML editor (right-click the file in the |
syeshin | d0bdb8e | 2005-10-27 17:44:14 +0000 | [diff] [blame] | 49 | Navigator view and click <b> <span class="uicontrol">Open With > XML Editor</span></b>). </span></li> |
syeshin | befd53e | 2005-07-27 18:16:40 +0000 | [diff] [blame] | 50 | <li class="skipspace"><span>For example, you have a DTD that specifies that an element requires |
| 51 | at least one of a specific child element: </span> <pre><!ELEMENT parentElement (childElement+)></pre> |
| 52 | </li> |
| 53 | <li class="skipspace"><span>If, in an XML file associated with your DTD, you attempt to remove |
| 54 | the final child element of the element with the DTD constraints turned on, |
| 55 | the editor will not allow you to do this, as it will make the document invalid.</span> You can confirm this by using the element's pop-up menu to verify that |
syeshin | d0bdb8e | 2005-10-27 17:44:14 +0000 | [diff] [blame] | 56 | the<span class="uicontrol"> <b>Remove</b></span> option is grayed out.</li> |
| 57 | <li class="skipspace"><span>To turn the DTD constraints off, click <b> <span class="uicontrol">XML > Turn Grammar |
| 58 | Constraints Off</span></b>. </span></li> |
syeshin | befd53e | 2005-07-27 18:16:40 +0000 | [diff] [blame] | 59 | <li class="skipspace"><span>If you attempt to remove the same child element with constraints |
| 60 | off, the editor will allow you to.</span></li> |
| 61 | <li class="skipspace"><span>To correct the invalid document, you will have to re-add the necessary |
| 62 | element, or remove the invalid tagging or value.</span></li> |
| 63 | </ol> |
| 64 | <div class="skipspace">If you introduce errors into your files, you must save and validate |
| 65 | the file in order to see a list of the errors you have introduced. They will |
| 66 | be listed in the Problems view. After you fix the errors, you must save and |
| 67 | validate your file again to see if the file is now valid.</div> |
| 68 | </div> |
| 69 | |
| 70 | <div> |
| 71 | |
| 72 | <p><b class="relconceptshd">Related concepts</b><br /> |
| 73 | <a href="../topics/cxmlcat.html" title="There are two different ways to associate XML files with DTDs or XML schemas.">XML file associations with DTDs and XML schemas</a><br /> |
| 74 | </p> |
| 75 | <p><b class="reltaskshd">Related tasks</b><br /> |
| 76 | <a href="../topics/tedtdoc.html" title="The DOCTYPE declaration in an XML file is used at the beginning of it to associate it with a DTD file. You can edit your DOCTYPE declaration to change the DTD file your XML file is associated with.">Editing your DOCTYPE declaration</a><br /> |
syeshin | d0bdb8e | 2005-10-27 17:44:14 +0000 | [diff] [blame] | 77 | <a href="../topics/txmlcat.html" title="Adding an entry to the XML Catalog">Adding an entry to the XML Catalog</a><br /> |
syeshin | befd53e | 2005-07-27 18:16:40 +0000 | [diff] [blame] | 78 | <a href="../topics/tedtgram.html" title="If you make changes to a DTD file or XML schema associated with an XML file (that is currently open), click XML > Reload Dependencies to update the XML file with these changes.">Updating XML files with changes made to DTDs and schemas</a><br /> |
syeshin | d0bdb8e | 2005-10-27 17:44:14 +0000 | [diff] [blame] | 79 | <a href="../topics/tedtsch.html" title="Your namespace information is used to provide various information about the XML file, such as the XML schema it is associated with.?">Editing your namespace information</a><br /> |
syeshin | befd53e | 2005-07-27 18:16:40 +0000 | [diff] [blame] | 80 | </p> |
syeshin | 6607827 | 2005-09-20 16:53:38 +0000 | [diff] [blame] | 81 | </div> |
syeshin | befd53e | 2005-07-27 18:16:40 +0000 | [diff] [blame] | 82 | </body> |
| 83 | </html> |