How to create an XML development environment

Source: Internet
Author: User
The best way to learn XML is from simple development, brave practices, and gradual development. The beauty of XML is that it can only be understood in the development process. XML cannot be learned without development. Therefore, to learn XML, you must first establish an XML development environment.

The best way to learn XML is from simple development, brave practices, and gradual development. The beauty of XML is that it can only be understood in the development process. XML cannot be learned without development. Therefore, to learn XML, you must first establish an XML development environment. Let me show you how to build a Java-based XML development environment. Since I have no way to use Linux now, all examples are made on Windows. However, all the software mentioned here can be used on Linux and Windows, and the usage is similar. Besides Sun's JRE, it is open source software. anyone can use it for any purpose, or even re-release of trade targets. JRE can also be downloaded and applied for free, but there is no source code. If you have experience using these software on Linux, I hope you can contribute.

To create an XML development environment, follow these steps:

1. Install Java runtime environment

2. install a Java compiler

3. install a JSP Container

4. install a taglib supporting XSLT

5. install an XML Parser

6. install a browser supporting XSLT

7. install an XML file editor (optional)

Step 1. Install Java runtime environment

We recommend Sun's JRE 1.3 application, which can be downloaded from here:

Http://java.sun.com/j2se/1.3/jre/download-windows.html

Note: instead of JDK 1.3, all we need is JRE 1.3.

After JRE 1.3 is downloaded, run the installer. assume that the installer is installed under C: \ JRE1.3. Then you need to set three environment variables.

JAVA_HOME = C: \ JRE1.3

CLASSPATH =.; C: \ JRE1.3 \ lib \ rt. jar
PATH = % PATH %; C: \ JRE1.3 \ bin

For Windows 95/98/me, place the environment variable settings in Autoexec. bat and restart the machine. Windows NT/2000 can be set in "My computer/properties.


Step 2. install a Java compiler

We recommend that you use IBM jikes, an efficient open source Java compiler. The home page of jikes is

Http://oss.software.ibm.com/developerworks/opensource/jikes/

The latest version is 1.1.3. you can download it from here:

Http://oss.software.ibm.com/pub/jikes/jikes-1_13-mingw-win32.zip

Download and decompress the package to obtain jikes.exe, which is placed in the directory of any PATH environment variable, such as C: \ JRE1.3 \ bin.

Compile a simple hello world program and try it:

// Hello. java
Public class hello {
Public static void main (String [] args ){
System. out. print ("hello, world! \ N ");
}
}

Then compile

Jikes hello. java

If you are born with hello. class, you can use it.

Step 3. install a JSP Container

Tomcat 3.2.1 of Jakarta is recommended. Tomcat 3.2.1 can be downloaded from here:

Http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.1/bin/

You need to download the jakarta-tomcat-3.2.1.zip file

For example, if you install it in Windows NT/2000, there is also jk_nt_service.zip in the win32/i386 directory.

Download and decompress the package. assume that the package is under C: \ tomcat.

Then you need to set an environment variable.

TOMCAT = C: \ tomcat

To enable Tomcat to apply jikes, you need to do a little bit of hack as follows:

Add parser. jar, jaxp. jar, and webserver. jar under the lib directory of tomcat to the environment variable CLASSPATH, and perform the following steps after taking effect:

Cd \ tomcat \ src \ org \ apache \ tomcat \ context

Compile the WebXmlReader. java file

// Sw. addInitParam ("jspCompilerPlugin", "org. apache. jasper. compiler. JikesJavaCompiler ");

Comment out

Then compile

Jikes WebXmlReader. java

Create a temporary directory and use the jar tool (which can be obtained from JDK) to decompress webserver. jar under the lib directory of Tomcat.

Mkdir t

Cd t

Jar xvf .. \ webserver. jar

Change the WebXmlReader *. class under org \ apache \ tomcat \ context to the naturally compiled WebXmlReader *. class.

Then re-package:

Jar cf webserver. jar.

Use the new webserver. jar file to change Tomcat's webserver. jar file.

Compile the web. xml in the conf directory of Tomcat

Comment out.

Compile Tomcat. bat in the bin directory of tomcat and change all tools. jar to rt. jar.

Start tomcat and run startup. bat in the bin directory.

Test the application browser and visit

Http: // localhost: 8080

If JSP and Servlet examples can both be compiled and run, Tomcat can be used.

End Tomcat with shutdown. bat

In Windows NT/2000, you can install tomcat as a service by using the following methods:

Copy wrapper. properties under the conf directory of Tomcat and compile it. Set the two variables

Wrapper. tomcat_home

Wrapper. java_home

Set it to the installation path of TOMCAT and JRE, and change all tools. jar to rt. jar.

Then run

Jk_nt_service-I Tomcat wrapper. properties

Tomcat is the name of the service we have installed.

Enter the control panel to start Tomcat service. After Tomcat service is installed, set it to manual start. you can modify the attributes of Tomcat service to enable it to start automatically.

To delete a Tomcat service:

Jk_nt_service-R Tomcat

Step 4. install a taglib supporting XSLT

We recommend that you use the XSL Taglib for XSLT in Jakarta Taglibs.

Its page is in http://jakarta.apache.org/taglibs/doc/xsl-doc/intro.html

The snapshot of XSL Taglib is loaded from the page. You can also download all Jakarta Taglibs. Jakarta Taglibs is widely used, but here we only need to use XSL Taglib.

Decompress the package, copy the xsl-examples.war and xsl-doc.war files to the webapps directory of Tomcat, and restart Tomcat. Application browser visit

Http: // localhost: 8080/xsl-examples/

Run Apply. jsp on the page. if there is no error, a page with many tables is displayed, and XSL Taglib can be used.

The documentation for XSL Taglib is also installed.

Http: // localhost: 8080/xsl-doc/

From this example, you can start to write your own XML processing program step by step. For example, you can add a new Context in Tomcat server. xml.

DocBase = "path-to-your-work-directory"
CrossContext = "false"
Debug = "0"
Reloadable = "true">

Path-to-your-work-directory is your development directory. Copy the content in the Tomcat webapps/xsl-examples directory to your development directory, and write your own XML processing program as a reference.

For how to apply JSP for XML development can refer to Sun's white ***, in: http://java.sun.com/products/jsp/pdf/JSPXML.pdf

This is based on the method I told you above.


Step 5. install an XML Parser

After completing steps 3 and 4, you already have two available XML Parser, that is, the Xerces of Sun JAXP and xml.apache.org of The XSL Taglib application of Tomcat. JAXP contains two files: parser. jar and jaxp. jar. Xerces has only one file, xerces. jar, which can be found in the Tomcat directory.

We recommend Xerecs, XML Parser, because it supports XML Schema and is open source software. However, Sun's XML Parser is also outstanding for its personal interests. Determine which XML Parser to apply and add the file to CLASSPATH. But do not apply two XML Parser at the same time.

After CLASSPATH takes effect, you can apply the JDOM and SAX APIs to your Java program to process XML files.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.