[Developer Guide] How to use the XML editor in MyEclipse

The XML editor includes advanced XML editing features. Through this article, you will learn about its editing function and web page XML editing, let's take a look~

1. Web XML editor

MyEclipse Web XML Editor includes advanced XML editing features such as:

  • syntax highlighting
  • Tag and Attribute Content Assist
  • Live validation (as you type)
  • Source view, Design view, and Outline view of document content
  • document format
  • Content Assist Template

When you create a Web project, the New Web Project wizard places a default Web.xml file in the project's Web-inf folder. To open the web.xml file, double-click it in the Project Explorer view. Open the WebDeployment Descriptor editor. Although the Web Deployment Descriptor editor provides a Source view of the Web .xml file (by clicking the Source tab), using the Design view is easier and introduces fewer errors. When you make changes to these pages, the web.xml file will automatically update for you.

Web Deployment Descriptor editor for XML files 

The tree structure is also displayed in the outline view and the Project Explorer view, and provides easy navigation to various parts of the web.xml file.

​Outline view

2. Web XML editing

To edit a deployment descriptor, click a node in the tree to locate the property to add, edit, or delete. The web deployment descriptor editor allows you to specify deployment information for modules created in the web development environment. This information appears in the WebContent/WEB-INF/web.xml file. Note that you use the web deployment descriptor to set deployment descriptor properties. You cannot use it to directly manipulate web resource content.

Editing Web.XML files with the MyEclipse Web XML editor can be done in two different modes: design mode and source mode. You can switch between the two modes using the tabs at the bottom of the editor.

Use tabs to switch modes

Switching between the two modes can be done at any time as they are both automatically kept in sync with each other.

2.1 Web XML Design Patterns

When you open the web.xml document in design mode for the first time, it looks like the image below.

design view

In design mode, the contents of the web.xml document are shown to you in a "super" outline view. On the left there are the tags that make up the document, they are represented in a tree, and each tag can be edited. Clicking on any tag in the tree will display the properties of that tag in edit mode on the right, making it very easy to understand and edit web.xml files intuitively without worrying about syntax.

Another nice feature of Design Patterns is that you can add, remove, and edit markup visually, whereas Designer only presents you with the option to properly align with the DTD or Schema referenced by the document. More specifically, this design does not allow you to insert invalid tags or attributes.

For example, suppose you want to add a "context-param" parameter to your XML document. 'context-param' is a simple name/value pair with an optional description. Select the "Context Parameters" node in the tree and click the "Add" icon.

Add context parameter

Depending on the Schema referenced by the documentation, there can be zero or more context parameters in any given web.xml file. They consist of a name, a value, and an optional description. Param-Name and Param-Value are determined by the frameworks you use and the parameters those frameworks expect to see. This example uses JSF and specifies where the configuration file resides at runtime. Other frameworks use other parameters.

Add context parameter values

After adding tags, you can edit the value or add/remove tags without switching to source mode to edit. Double-click the field to edit.

Edit context parameters

2.2 Web XML source schema

While editing XML documents in design mode is sometimes easier and avoids making mistakes, it is also convenient to work directly with the source code. MyEclipse's XML editor provides extensive source code editing capabilities.

When you first open an XML document in source mode, it looks like this:

​source view

Note: The red underline in the screenshot above is from the Universal Editor spell checker. You can enable or disable the spell checker for all editors according to your preference.

While working with XML source editors, you may have noticed some really nice tools. For example, if you type the wrong tag or attribute name, the editor will flag the line as an error (check against the DTD or Schema referenced by the document).

XML errors are flagged

To make editing easier, content assist is available for tags and attributes. Content assist is also context-aware, so it won't suggest unreasonable completion options to you based on the position of the cursor and the DTD or schema referenced by the XML file.

​Content Assist helps complete code

Much of the functionality provided by the MyEclipse Web XML Editor relies on the document's reference to a DTD or Schema, so the editing tool can validate your work against the specification and provide content assistance. If you're editing a plain XML file that doesn't provide a DTD or Schema, the editor still gives you syntax highlighting and basic content assistance as well as basic validation (like unclosed tags). However, some more advanced editing features are not available. (MyEclipse technical exchange group: 742336981)

The above is the whole content of this article. If you have any questions and need to know more details, please comment or chat with me privately~

Guess you like

Origin blog.csdn.net/m0_67129275/article/details/130923354