Give the power of XML through Eclipse (12)

xiaoxiao2021-03-06  48

This article outlines how the Eclipse platform supports XML (Extensible Markup Language, Extensible Markup Language). Eclipse does not directly support XML code editing. However, because Eclipse is a frame-independent framework for building a developer tool, it is possible to add support for new languages ​​relatively easily.

Many XML plugins have been developed, and new plugins are constantly being created. This article mainly discusses plugins called XMLBuddy because it is rich in functions that contain most of the features needed to develop XML document development. We will also mention other plugins that provide a richer user option set for specific tasks. This article will make you familiarize yourself with basic XML editing features, but remember: Eclipse is a dynamic frameset that allows numerous tools and features to use.

The Eclipse XML editor Eclipse already includes a very simple XML editor source code, which only provides highlighting of XML syntax. It inherits the class included in the org.eclipse.ui.editors package, which provides a standard text editor and file-based document provider for the Eclipse platform. This simple XML editor works in the code example, you can use it as the basis of your own Eclipse XML plugin. Its source code can only be generated by the Eclipse project wizard, you need to compile it as described below.

To build this basic XML editor, go to menu file => New, then select Project. In the Project Wizard, select Plug-in Development => Plug-in Project.

If the Plug-in Developments option is not seen, the Eclipse platform Runtime Binary does not have a PLUG-IN development environment. Please go to the Eclipse.org download page (see later in this article)

References to get links) Download the Eclipse platform Plug-in SDK.

Click Next. Name (such as org.my.eclipse.xmleditor), click Next, then accept the default value on the screen Plug-In Project Structure. Next, select the Create A Plug-In Project Using A Code Generation Wizard, then select the Plug-IN with an Editor option. The wizard automatically generates the source code of the XML editor.

But still need to compile it. Click Next, then click Finish option on the next screen Simple Plug-in Content; go to the Project menu and select Rebuild All to build the project.

Next, you need to create an editor.jar file using the file => Export menu. Exit Eclipse and copy the entire Org.my.eclipse.xmleditor plugin directory. When you run Eclipse again, you can add an XML file to your project to learn how the XML syntax highlights how to work (see Figure 1). Keep in mind that this sample XML editor does not provide any authentication or syntax check.

Figure 1. Simple syntax highlighted by the Eclipse XML editor

Write XML The most popular and most advanced Eclipse XML editor plugins developed by Bocaloco Software (see Resources for Link). XMLBuddy is a free plug-in, which adds XML editing capabilities for Eclipse, including an outline view of the user-configurable syntax coloring, DTD-driven code assist, verification, and synchronization. XML Buddy also adds an XML perspective for Workspace to add new project templates for XML documents and DTD. You can install XMLBUDDY like any other Eclipse plugin: Simply decompress the plugin compressed file to the / Eclipse / PLUGINS subdirectory in the main Eclipse installation directory. Remember to restart Eclipse. Figure 2 shows the XMLBuddy in the operation. Figure 2. XMLBuddy: Main Editor Window with XML Outline View

XML is a meta-marker language. The XML element consists of the starting mark, the end tag, and the data between the two, so the syntax highlighting also needs good editing functions. XMLBUDDY (currently version 0.2) Extension Eclipse with the following XML editing function:

format. You can automatically format the entire XML document or some document by selecting all or part of the code. Advanced grammar coloring. The XML code coloring can be configured by window => preferences => xml => colors menu. Coloring can be used in ordinary XML documents, DTDs (internal or external subsets) and JSP files. Figure 3 shows how to change the default settings that highlight the syntax.

Figure 3. Changing the default settings that highlight the XML syntax

XML code assist. Depending on the DTD of the document, you can provide assistance for the element or other tag name, attribute name, and attribute value. Extended character encoding support. XMLBUDDY automatically detects document encoding according to XML 1.0 specification, which accepts

Posted on September 02, 2003 11:25 pm

转载请注明原文地址:https://www.9cbs.com/read-116388.html

New Post(0)