Home > Article > Backend Development > Detailed explanation of establishing XML development environment
[Introduction] The best way to learn xml is to start with simple development, practice boldly, and proceed step by step. The beauty of XML can only be deeply understood during the development process. It is impossible to learn XML without development. Therefore, to learn XML, you should first establish an XML development environment. Let me introduce to you
The best way to learn xml is to start with simple development, practice boldly, and proceed step by step. The beauty of XML can only be deeply understood during the development process. It is impossible to learn XML without development. Therefore, to learn XML, you should first establish an XML development environment. Let me introduce to you how to establish an XML development environment based on java. Since I don't have access to linux right now, all the examples are done on Windows. However, all the software introduced here can be used on Linux and Windows, and the usage is similar. And except for Sun's JRE, it is all open source software, and anyone can use it for any purpose, even redistribution for commercial purposes. JRE is also free to download and use, but there is no source code. If you have experience using these software on Linux, I hope you can contribute to everyone.
Establishing an XML development environment requires the following steps:
1. Install Java runtime environment
2. Install a Java compiler.
3. Install a jsp Container.
4. Install a taglib that supports XSLT.
5. Install an XML Parser.
6. Install a browser that supports XSLT.
7. Install an XML file editor (optional).
step 1. Install Java runtime environment
It is recommended to use Sun's JRE 1.3, which can be downloaded from here:
http://java.sun.com/j2se/1.3/jre/download-windows.html
Note: Not JDK 1.3, all we need is JRE 1.3
After downloading JRE 1.3, run the installation program, assuming it 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
If it is Windows 95/98/me, put the environment variable settings in Autoexec.bat, then restart the machine. For Windows NT/2000, just set them in "My Computer/Properties".
Step 2: Install a Java compiler.
It is recommended to use IBM's jikes, an efficient open source Java compiler. The homepage of jikes is at
http://oss.software.ibm.com/developerworks/opensource/jikes/
The latest version is 1.1.3, which can be downloaded from here:
http://oss. software.ibm.com/pub/jikes/jikes-1_13-mingw-win32.zip
Download and unzip it to get a jikes.exe and place it in any directory in the PATH environment variable, such as C:\JRE1. 3\bin
Edit a simple hello world program to try:
// hello.java
public class hello {
public static void main(String [] args) {
System.out.PRint("hello, world!\n");
}
}
Then compile
jikes hello.java
If hello is generated .class is ready to use.
Step 3. Install a JSP Container.
It is recommended to use Jakarta’s Tomcat 3.2.1. 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 jakarta-tomcat-3.2.1. zip file
If you are installing under Windows NT/2000, there is also jk_nt_service.zip in the win32/i386 directory.
Decompress after downloading, assuming it is placed in C:\tomcat
Then you need to set an environment variable
TOMCAT=C:\tomcat
In order to enable Tomcat to use jikes, You need to do a little hack, the method is as follows:
Add parser.jar, jaxp.jar, webserver.jar in tomcat's lib directory to the environment variable CLASSPATH, make it effective and then perform the following steps:
cd \ tomcat\src\org\apache\tomcat\context
Edit the file WebXmlReader.java and add
// sw.addInitParam("jspCompilerPlugin", "org.apache.jasper.compiler.JikesJavaCompiler");
Remove the previous comments
and then compile
jikes WebXmlReader.java
Create a temporary directory and use the jar tool (can be obtained from the JDK) to decompress the webserver in Tomcat's lib directory. jar
mkdir t
cd t
jar xvf ..\webserver.jar
Replace the WebXmlReader*.class under org\apache\tomcat\context with the WebXmlReader*.class just compiled and generated
Then repackage:
jar cf webserver.jar .
Replace Tomcat’s webserver.jar with the new webserver.jar
Edit the web.xml in Tomcat’s conf directory and change
.
Edit tomcat.bat in Tomcat's bin directory and replace all tools.jar with rt.jar
Start tomcat and run startup.bat in the bin directory.
Use a browser to do a test and visit
http://localhost:8080
If the JSP and Servlet examples can be compiled and run, Tomcat can be used.
Stop Tomcat using shutdown.bat
Under Windows NT/2000, you can install tomcat as a service. The method is as follows:
Copy the wrapper.properties in the conf directory of Tomcat and edit it . Change two of the variables
wrapper.tomcat_home
wrapper.java_home
is set to the installation path of TOMCAT and JRE respectively, and replaces all tools.jar with rt.jar.
Then run
jk_nt_service -I Tomcat wrapper.properties
where Tomcat is the name of the service we installed.
Enter the control panel to start the Tomcat service. After the Tomcat service is installed, it is set to start manually. You can modify the properties of the Tomcat service to make it start automatically.
Delete Tomcat service using:
jk_nt_service -R Tomcat
Step 4. Install a taglib that supports XSLT.
It is recommended to use XSL Taglib in Jakarta Taglibs for XSLT
The page is at http://jakarta.apache.org/taglibs/doc/xsl-doc/intro.html
Download XSL Taglib from this page snapshot. You can also download all Jakarta Taglibs. Jakarta Taglibs have a wide range, but here we are only going to use the XSL Taglib.
After downloading, unzip it, copy the two files xsl-examples.war and xsl-doc.war to Tomcat's webapps directory, and then restart Tomcat. Use a browser to access
http://localhost:8080/xsl-examples/
and run Apply.jsp in the page. If there are no errors and a page with many tables is displayed, XSL Taglib can be used.
XSL Taglib's documentation is also installed, at
http://localhost:8080/xsl-doc/
You can start from this example and start writing your own XML step by step handler. For example, you can add a new Context
crossContext="false in Tomcat's server.xml "
debug="0"
reloadable="true" >
The path-to-your-work-directory is your development directory. Copy the contents of Tomcat's webapps/xsl-examples directory intact to your development directory, and use this program as a reference to start writing your own XML processing program.
Regarding how to use JSP for XML development, you can refer to Sun's whitepaper, at: http://java.sun.com/products/jsp/pdf/JSPXML.pdf
What I talked about is basically what I said above Tell you this method.
Step 5. Install an XML Parser.
After completing steps 3 and 4, you already have two available XML Parsers, which are Sun's JAXP used by Tomcat itself and xml.apache.org's Xerces used by XSL Taglib. JAXP includes two files, parser.jar and jaxp.jar, while Xerces has only one file, xerces.jar. These files can be found in the Tomcat directory.
It is recommended to use Xerecs, the XML Parser, because it currently supports XML Schema and it is open source software. But this is purely a matter of personal preference, and Sun's XML Parser is also excellent. After deciding which XML Parser to use, add its files to CLASSPATH. But don't use both XML Parsers at the same time. After CLASSPATH takes effect, you can use JDOM and SAX APIs to process XML files in your Java program.
Examples of applicable occasions and usage of JDOM and SAX can be found here: http://developerlife.com
Step 6. Install a browser that supports XSLT.
This step is not necessary, because we can now use XSL Taglib on the server side to convert the XML file into HTML format and send it to the Browser, so in fact you can use any browser you like. But installing a browser that supports XSLT can facilitate our learning. Although we need to do XSLT on the server side now, when browsers that support XSLT become popular in the future, we can even skip this step and just send the XML and XSL files directly to the browser. This can greatly reduce the burden on the server side, because doing XSLT is not an easy task.
Recommended to use Mozilla 0.8. At this point, you may want to ask again, why not use IE 4/5? Can't IE 4/5 also do XSLT? In addition to personal preference, I can cite 3 reasons for using Mozilla:
First of all, the XSLT version supported by Mozilla is newer than IE 4/5. The XSLT supported by IE 4/5 is not an official version, but a draft. That is: http://www.w3.org/TR/WD-xsl, and the XSLT supported by Mozilla is the official version of XSLT. Namely: http://www.w3.org/1999/XSL/Transform.
Secondly, XML applications in Mozilla include not only XSLT, but also RDF, XUL, SVG, MathML, etc., so Mozilla's support for XML exceeds IE 4/5 in breadth and depth.
The author of the third XML FAQ highly praises Mozilla and believes that Mozilla's support for XML is much better than IE 4/5 in terms of robustness.
OK, having said so much, let’s turn to the topic now, how to make Mozilla 0.8 support XSLT?
First, download Mozilla 0.8 from here: http://www.mozilla.org/releases/
The latest is version 0.8.1, but this version cannot run after installing a module that supports XSLT, so it is still available Only the older but slower version 0.8 can be used.
If you no longer want other features such as SVG/MathML, the most convenient way is to install it using the prepared .exe file.
After the installation is complete, start Mozilla and visit this page: http://www.mozilla.org/projects/xslt/
There is an Install button on the page. Click this button to install the TransforMiiX module that implements the XSLT function.
Restart Mozilla and visit the page mentioned above. Click on the link to the simple example above. If you see the same results as clicking the look like link, then your Mozilla already supports XSLT.
Regarding how to configure Mozilla 0.8 to support Java Plug-in, please refer to another post I posted on the XML version: XML client solution based on Mozilla, I won’t go into details here.
Step 7. Install an editor for XML files.
This step is not necessary. Have you heard that people still use vi to create HTML pages? I have seen such a person, and that is Teacher Yu Mingjian. There is a striking sentence on Teacher Yu’s personal homepage: Just vim it! In fact, you can use any editor you like to edit XML files, but for the convenience of friends who are used to using WYSIWYG editors, I still recommend a few comparisons Good XML editor:
1. XML Spy: A full-featured XML editor, a trial version is available for download.
http://www.xmlspy.com/
2. EditML Pro: Another comprehensive XML editor.
http://www.editml.com
3. PSGML for Emacs: Emacs, I don’t need to say anything, right?
http://www.lysator.liu.se/projects/about_psgml.html
Here is just to introduce some other knowledge to add to the cake. Using this knowledge we can build a A more powerful development environment.
Step 8. Install a better JSP Framework
It is recommended to use Struts. Struts is a sub-project of the Jakarta project, which aims to develop a JSP Framework based on the MVC design pattern. Developing within the Struts framework can effectively separate the presentation layer and implementation layer of Web applications and improve code reusability. Development based on the MVC design pattern is the so-called Model 2 development pattern. The project is currently nearing completion, and the latest version is 1.0-beta-1.
For information about what the MVC design pattern is, you can refer to the book "Design Patterns" by Machinery Industry Press. Regarding the usage of Struts, you can refer to the "Struts User Guide" I translated, which is in the article collection: http://www.linuxforum.net/doc/strutsuserguide.html
Download Jakarta Struts from here:
http://jakarta.apache.org/builds/jakarta-struts/release/v1.0-b1/
You need to download the jakarta-struts-1.0-b1.zip file.
Extract it, then copy the struts-example.war and struts-documentation.war files to Tomcat's webapps directory, and then restart Tomcat. Use a browser to visit
http://localhost:8080/struts-example/
Run the MailReader program on the page. If it can be registered correctly, it can be used.
The Struts documentation has also been installed, at
http://localhost:8080/struts-documentation/
For how to use Struts in your own development directory, please refer to the Struts package document. There are some discussions about Struts in Java Edition, which can be found using the forum's search function.
Step 9. Establishing a connection with Apache
This is already a long story. Let me introduce the simplest method, using mod_jk to establish a connection with Apache.
Assuming you have installed Apache, download mod_jk from here:
http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.1/bin/win32/i386/
You need to download the mod_jk.zip file.
Extract it to get a mod_jk.dll and copy it to the modules directory under the Apache installation directory.
Modify Apache's configuration file httpd.conf and add the following two lines:
Include C:/tomcat/conf/mod_jk.conf-auto
JkMount /*.do ajp12
where "C:/ "tomcat" is the installation directory of Tomcat.
Add index.jsp to DirectoryIndex, that is:
DirectoryIndex index.html index.jsp
If there is a comment before ServerName, open the comment before ServerName and set it to localhost, that is:
ServerName localhost
Restart Apache and visit this page:
http://localhost/examples/
If the jsp and servlet directories can be listed, the connection between Tomcat and Apache is established.
The above is the detailed content of Detailed explanation of establishing XML development environment. For more information, please follow other related articles on the PHP Chinese website!