Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Web Tools Guide
Previous Page Home Next Page

Editing with DTD or XML schema constraints

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.

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.

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.

To turn the constraints for an XML file off, click XML > Turn Grammar Constraints Off 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.

The following example shows what you can do if you turn the constraints of a DTD off:

  1. Open the XML file in the XML editor (right-click the file in the Navigator view and click Open With > XML Editor).
  2. You have a DTD that specifies that an element requires at least one of a specific child element:
    <!ELEMENT parentElement (childElement+)>
    
  3. 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. You can confirm this by using the element's pop-up menu to verify that the Remove option is grayed out.
  4. To turn the DTD constraints off, click XML > Turn Grammar Constraints Off.
  5. If you attempt to remove the same child element with constraints off, the editor will allow you to.
  6. To correct the invalid document, you will have to re-add the necessary element, or remove the invalid tagging or value.

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.

These instructions were written for the Resource perspective, but they will also work in many other perspectives.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire