This article mainly introduces how the eclipse platform supports XML development, and focuses on the xmlbuddy plug-in. Xmlbuddy, one of which is not about money, mainly provides functions such as DTD verification and code assistant, and xmlbuddy pro, which is about money, compared with xmlbuddy, it extends many functions, such as support for schema, XSLT, and relax ng. Xmlbuddy is enough for general XML writing, and it is free and easy to get, so I will focus on it here.
1. Download and install
1. DownloadXmlbuddy home address is: http://www.xmlbuddy.com/download to pay attention to xmlbuddy, not xmlbuddy pro. Here is an xmlbuddy 2.0.38 version: ipv3.0.1-3.1m5. For ease of explanation, I used eclipse 3.0.1 and installed a Chinese Language Pack without installing other plug-ins.
2. InstallationInstall xmlbuddy 2.0.38, decompress the downloaded file, and copy the com. objfac. xmleditor_2.0.38 directory to the Plugins directory under the eclipse installation directory. You can also install it using links. Start eclipse again and you will find that xmlbuddy has been installed.
3. CustomizationTo customize xmlbuddy, you can use
Window-> preferences-> xmlbuddyTo modify:
Ii. Use xmlbuddyNext we will explain how to use xmlbuddy: · Create a Java project named "xmlbuddydemo" and create a web. xml file. As follows:
<?xml version="1.0" encoding="GBK"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"><web-app><welcome-file-list><welcome-file>index.html</welcome-file></welcome-file-list></web-app>
· If the Internet is not connected at this time, for example, if you enter the code, the code prompt function will not appear. Connect to the Internet, reopen the Web. xml file, pause for a moment (xmlbuddy will automatically download the web-app_2_3.dtd), and then perform the operation: You can also use Alt +/for code prompts. · Code after completion:
<?xml version="1.0" encoding="GBK"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"><web-app><welcome-file-list><welcome-file>index.html</welcome-file></welcome-file-list><error-page><error-code>404</error-code><location>/error.jsp</location></error-page></web-app>
How is it convenient!
Supplement: If you open the eclipse directory/workspace /. metadata /. plugins/COM. objfac. xmleditor /. the "f1" file under the cache (not necessarily the F1 name, may be F2, F3 and other names), will find that this file is a web-app_2_3.dtd. If you cannot connect to the Internet, or the link contained in the namespace is invalid, You can first get the web-app_2_3.dtd file through another channel, such as placing it in the D:/XML directory, then you can directly reference it as follows:
<?xml version="1.0" encoding="GBK"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "file:///D:/xml/web-app_2_3.dtd"><web-app><welcome-file-list><welcome-file>index.html</welcome-file></welcome-file-list></web-app>
You can try
! DoctypeCan be deployed in Tomcat. · Xmlbuddy has other functions, such as "formatting" code.
Iii. digress
Other plug-ins, such as lomboz and JBoss-ide, can also edit XML files, but their performance is not as good as xmlbuddy. Note that after multiple plug-ins are installed, the default Opening Method of the XML file is not necessarily xmlbuddy (this is the result after JBoss-Ide is installed, you can right-click the XML file to be opened and select xmlbuddy to open it. eclipse will call xmlbuddy by default when the XML file is opened again. Of course, you can also choose another plug-in to open it. You can also modify the default Opening Method of the XML file (
Window-> preferences-> workbench-> File Association), You can even call an external software (such as XML spy) to operate XML files (if you think these plug-ins are not suitable ). In general, xmlbuddy is still very good for files whose XML document type is DTD, but it is not good for files whose XML document type is W3C XML Schema mode. Of course, you can use the xmlbuddy Pro version for editing, but it does not seem easy to use. Fortunately, most of them are DTD, so xmlbuddy is still used. Now, there is a project under eclipse, which is "Eclipse web tools platform project". The current version is 1.0m3, which is mainly used to develop J2EE and Web applications, of course, you can edit the XML file. I tried it for a while and I will give you a picture below to quench your thirst: In fact, I always think that XML files are a way for programs to communicate with each other, but it should not be a way for programs to communicate with programmers. I always think it's too cool, so I can't stand it, just like tang miao (joke and relax ). Therefore, I am reluctant to write XML files. XDoclet is often used to generate xml files. These are all irrelevant.