blob: 1693ebcd790ae21c258fd62411b5eb7b321f0dab [file] [log] [blame]
<?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 lang="en-us" xml:lang="en-us">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta name="copyright" content="Copyright (c) 2000, 2009 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" />
<meta name="DC.rights.owner" content="(C) Copyright 2000, 2009" />
<meta content="public" name="security" />
<meta content="index,follow" name="Robots" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta content="task" name="DC.Type" />
<meta name="DC.Title" content="Editing with DTD or XML schema constraints" />
<meta name="abstract" content="In the Design view, when you edit an XML file that has a set of constraints or rules defined by a DTD or an XML schema, you can turn the constraints on and off to provide flexibility in the way you edit, but still maintain the validity of the document periodically." />
<meta name="description" content="In the Design view, when you edit an XML file that has a set of constraints or rules defined by a DTD or an XML schema, you can turn the constraints on and off to provide flexibility in the way you edit, but still maintain the validity of the document periodically." />
<meta content="XML editor, editing with constraints, XML files" name="DC.subject" />
<meta content="XML editor, editing with constraints, XML files" name="keywords" />
<meta scheme="URI" name="DC.Relation" content="../topics/cxmlcat.html" />
<meta scheme="URI" name="DC.Relation" content="../topics/tedtdoc.html" />
<meta scheme="URI" name="DC.Relation" content="../topics/txmlcat.html" />
<meta scheme="URI" name="DC.Relation" content="../topics/tedtgram.html" />
<meta scheme="URI" name="DC.Relation" content="../topics/cxmlcat.html" />
<meta scheme="URI" name="DC.Relation" content="../topics/tedtsch.html" />
<meta scheme="URI" name="DC.Relation" content="../topics/txmlcat.html" />
<meta scheme="URI" name="DC.Relation" content="../topics/tedtgram.html" />
<meta content="XHTML" name="DC.Format" />
<meta content="tedtcnst" name="DC.Identifier" />
<meta content="en-us" name="DC.Language" />
<link href="../../org.eclipse.wst.doc.user/common.css" type="text/css" rel="stylesheet" />
<title>Editing with DTD or XML schema constraints</title>
</head>
<body id="tedtcnst"><a name="tedtcnst"><!-- --></a>
<h1 class="topictitle1">Editing with DTD or XML schema constraints</h1>
<div><p>In the Design view, when you edit an XML file that has a set of
constraints or rules defined by a DTD or an XML schema, you can turn the constraints
on and off to provide flexibility in the way you edit, but still maintain
the validity of the document periodically.</p>
<div class="section"><p> When the constraints are turned on, and you are working in the
Design view, the XML editor prevents you from inserting elements, attributes,
or attribute values not permitted by the rules of the XML schema or DTD, and
from removing necessary or predefined sets of tags and values. In this mode,
an element's content must be valid to use the XML editor's guided editing
options.</p>
<p>You might want to turn the constraints off for an XML file
if you need more flexibility. For example, you want to try working with elements
or attributes not permitted by the associated DTD or XML schema, without actually
removing the association with the DTD or XML schema.</p>
<p>To turn the constraints
for an XML file off, click <span class="menucascade"><span class="uicontrol">XML</span> &gt; <span class="uicontrol">Turn
Grammar Constraints Off</span></span> in the toolbar. After you
have turned the constraints off for a file, you can insert or delete any element
or attribute regardless of the DTD or XML schema rules. You can create new
elements or attributes that are not in the DTD or schema - these Design view
prompts will only appear when you have turned constraints off. The file might
not be valid, however, if you do this. </p>
<p>The following example shows
what you can do if you turn the constraints of a DTD off:</p>
</div>
<ol>
<li class="stepexpand"><span>Open the XML file in the XML editor (right-click the file in the
Navigator view and click <span class="uicontrol">Open With &gt; XML Editor</span>). </span>
</li>
<li class="stepexpand"><span>You have a DTD that specifies that an element requires at least
one of a specific child element: </span> <pre>&lt;!ELEMENT parentElement (childElement+)&gt;
</pre>
</li>
<li class="stepexpand"><span>If, in an XML file associated with your DTD, you attempt to remove
the final child element of the element with the DTD constraints turned on,
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
the <span class="uicontrol">Remove</span> option is grayed out.</li>
<li class="stepexpand"><span>To turn the DTD constraints off, click <span class="uicontrol">XML &gt; Turn Grammar
Constraints Off</span>. </span></li>
<li class="stepexpand"><span>If you attempt to remove the same child element with constraints
off, the editor will allow you to.</span></li>
<li class="stepexpand"><span>To correct the invalid document, you will have to re-add the necessary
element, or remove the invalid tagging or value.</span></li>
</ol>
<div class="section"><p>If you introduce errors into your files, you must
save and validate the file in order to see a list of the errors you have introduced.
They will be listed in the Problems view. After you fix the errors, you must
save and validate your file again to see if the file is now valid.</p>
<p>These
instructions were written for the Resource perspective, but they will also
work in many other perspectives.</p>
</div>
</div>
<div><div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="../topics/cxmlcat.html" title="When an XML file is associated with a DTD or XML schema, it is bound by any structural rules contained in the DTD or XML schema. To be considered a valid XML file, a document must be accompanied by a DTD or an XML schema, and conform to all of the declarations in the DTD or the XML schema.">XML file associations with DTDs and XML schemas</a></div>
</div>
<div class="reltasks"><strong>Related tasks</strong><br />
<div><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 DOCTYPE declarations</a></div>
<div><a href="../topics/txmlcat.html" title="XML Catalog entries are used to map external entity references to locally defined resources. You can provide rules specify how these entities are resolved">Adding entries to the XML Catalog</a></div>
<div><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 &gt; Reload Dependencies to update the XML file with these changes. The changes will be reflected in the guided editing mechanisms available in the editor, such as content assist.">Updating XML files with changes made to DTDs and schemas</a></div>
<div><a href="../topics/tedtsch.html" title="Your namespace information is used to provide various information about the XML file, such as the XML schema and namespace it is associated with. If desired, you can change the schema and namespace your XML file is associated with or add a new association. Modifying any associations can impact what content is allowed in the XML file.">Editing namespace information</a></div>
</div>
</div>
</body>
</html>