kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 1 | <?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
|
| 10 | constraints (that is, a set of rules) defined by a DTD or an XML schema, you
|
| 11 | can turn the constraints on and off to provide flexibility in the way you
|
| 12 | edit, but still maintain the validity of the document periodically.</shortdesc>
|
| 13 | <prolog><metadata>
|
kprice | 9623e9d | 2007-05-03 03:43:05 +0000 | [diff] [blame] | 14 | <keywords><indexterm>XML editor<indexterm>editing with constraints</indexterm></indexterm>
|
| 15 | <indexterm>XML files<indexterm>editing with constraints</indexterm></indexterm>
|
| 16 | </keywords>
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 17 | </metadata></prolog>
|
| 18 | <taskbody>
|
| 19 | <context><p> When the constraints are turned on, and you are working in the
|
| 20 | Design view, the XML editor prevents you from inserting elements, attributes,
|
| 21 | or attribute values not permitted by the rules of the XML schema or DTD, and
|
| 22 | from removing necessary or predefined sets of tags and values. In this mode,
|
| 23 | an element's content must be valid to use the XML editor's guided editing
|
| 24 | options.</p><p>You might want to turn the constraints off for an XML file
|
| 25 | if you need more flexibility. For example, you want to try working with elements
|
| 26 | or attributes not permitted by the associated DTD or XML schema, without actually
|
| 27 | removing the association with the DTD or XML schema.</p><p>To turn the constraints
|
| 28 | for an XML file off, click <uicontrol>XML > Turn Grammar Constraints Off</uicontrol>.
|
| 29 | After you have turned the constraints off for a file, you can insert or delete
|
| 30 | any element or attribute regardless of the DTD or XML schema rules. You can
|
| 31 | create new elements or attributes that are not in the DTD or schema - these
|
| 32 | Design view prompts will only appear when you have turned constraints off.
|
| 33 | The file might not be valid, however, if you do this. </p><p>The following
|
| 34 | instructions were written for the Resource perspective, but they will also
|
| 35 | work in many other perspectives.</p><p>The following example shows what you
|
| 36 | can 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
|
| 39 | Navigator 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
|
| 42 | one of a specific child element: </cmd><info><codeblock><!ELEMENT parentElement (childElement+)>
|
| 43 | </codeblock></info></step>
|
| 44 | <step><cmd>If, in an XML file associated with your DTD, you attempt to remove
|
| 45 | the final child element of the element with the DTD constraints turned on,
|
| 46 | the 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
|
| 48 | the <uicontrol>Remove</uicontrol> option is grayed out.</info></step>
|
| 49 | <step><cmd>To turn the DTD constraints off, click <uicontrol>XML > Turn Grammar
|
| 50 | Constraints Off</uicontrol>. </cmd></step>
|
| 51 | <step><cmd>If you attempt to remove the same child element with constraints
|
| 52 | off, the editor will allow you to.</cmd></step>
|
| 53 | <step><cmd>To correct the invalid document, you will have to re-add the necessary
|
| 54 | element, 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
|
| 57 | the file in order to see a list of the errors you have introduced. They will
|
| 58 | be listed in the Problems view. After you fix the errors, you must save and
|
| 59 | validate your file again to see if the file is now valid.</result>
|
| 60 | </taskbody>
|
| 61 | </task>
|
| 62 | <?Pub *0000003854?>
|