blob: 63f1b5c77d49147040104ed991f027964bf291de [file] [log] [blame]
kpriceef160682006-08-29 18:08:31 +00001<?xml version="1.0" encoding="utf-8"?>
2<!--Arbortext, Inc., 1988-2005, v.4002-->
3<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
4<task id="tedtcnst" xml:lang="en-us">
5<title>Editing with DTD or XML schema constraints</title>
6<titlealts>
7<searchtitle>Editing with DTD or XML schema constraints</searchtitle>
8</titlealts>
9<shortdesc>In the Design view, when you edit an XML file that has a set of
10constraints (that is, a set of rules) defined by a DTD or an XML schema, you
11can turn the constraints on and off to provide flexibility in the way you
12edit, but still maintain the validity of the document periodically.</shortdesc>
13<prolog><metadata>
kprice9623e9d2007-05-03 03:43:05 +000014<keywords><indexterm>XML editor<indexterm>editing with constraints</indexterm></indexterm>
15<indexterm>XML files<indexterm>editing with constraints</indexterm></indexterm>
16</keywords>
kpriceef160682006-08-29 18:08:31 +000017</metadata></prolog>
18<taskbody>
19<context><p> When the constraints are turned on, and you are working in the
20Design view, the XML editor prevents you from inserting elements, attributes,
21or attribute values not permitted by the rules of the XML schema or DTD, and
22from removing necessary or predefined sets of tags and values. In this mode,
23an element's content must be valid to use the XML editor's guided editing
24options.</p><p>You might want to turn the constraints off for an XML file
25if you need more flexibility. For example, you want to try working with elements
26or attributes not permitted by the associated DTD or XML schema, without actually
27removing the association with the DTD or XML schema.</p><p>To turn the constraints
28for an XML file off, click <uicontrol>XML > Turn Grammar Constraints Off</uicontrol>.
29After you have turned the constraints off for a file, you can insert or delete
30any element or attribute regardless of the DTD or XML schema rules. You can
31create new elements or attributes that are not in the DTD or schema - these
32Design view prompts will only appear when you have turned constraints off.
33The file might not be valid, however, if you do this. </p><p>The following
34instructions were written for the Resource perspective, but they will also
35work in many other perspectives.</p><p>The following example shows what you
36can do if you turn the constraints of a DTD off:</p></context>
37<steps>
38<step><cmd>Open the XML file in the XML editor (right-click the file in the
39Navigator view and click <uicontrol>Open With > XML Editor</uicontrol>). </cmd>
40</step>
41<step><cmd>You have a DTD that specifies that an element requires at least
42one of a specific child element: </cmd><info><codeblock>&lt;!ELEMENT parentElement (childElement+)>
43</codeblock></info></step>
44<step><cmd>If, in an XML file associated with your DTD, you attempt to remove
45the final child element of the element with the DTD constraints turned on,
46the editor will not allow you to do this, as it will make the document invalid.</cmd>
47<info>You can confirm this by using the element's pop-up menu to verify that
48the <uicontrol>Remove</uicontrol> option is grayed out.</info></step>
49<step><cmd>To turn the DTD constraints off, click <uicontrol>XML > Turn Grammar
50Constraints Off</uicontrol>. </cmd></step>
51<step><cmd>If you attempt to remove the same child element with constraints
52off, the editor will allow you to.</cmd></step>
53<step><cmd>To correct the invalid document, you will have to re-add the necessary
54element, or remove the invalid tagging or value.</cmd></step>
55</steps>
56<result>If you introduce errors into your files, you must save and validate
57the file in order to see a list of the errors you have introduced. They will
58be listed in the Problems view. After you fix the errors, you must save and
59validate your file again to see if the file is now valid.</result>
60</taskbody>
61</task>
62<?Pub *0000003854?>