Xml
The best way to learn XML is to start with simple development, to practice boldly, and to step through it. The beauty of XML can only be deeply realized in the process of development, and it is difficult to learn XML without development. So learning XML should first build an XML development environment. Let me show you how to build a Java-based XML development environment. Because I can't use Linux now, all the examples are done on Windows. But all of the software described here is available on Linux and Windows, and the usage is similar. In addition to the Sun's JRE are open source software, anyone can be used for any purpose, or even commercial purposes of the redistribution. JRE can also be downloaded and used for free, just without source code. If you have the experience of using these software on Linux, I hope to contribute to you.
Building an XML development environment requires the following steps:
1. Install Java Runtime Environment
2. Installs a Java compiler.
3. Install a JSP Container.
4. Installs a taglib that supports XSLT.
5. Installs an XML Parser.
6. Installs a browser that supports XSLT.
7. Installs an editor for an XML file (optional).
Step 1. Install Java Runtime Environment
It is recommended that you use Sun JRE 1.3, which you can download from:
Http://java.sun.com/j2se/1.3/jre/download-windows.html
Note: Not JDK 1.3, all we need is JRE 1.3
Run Setup after downloading JRE 1.3, assuming the installation is under C:\JRE1.3. Then you need to set up 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, place the settings of the environment variable in Autoexec.bat, and then restart the machine, Windows nt/2000 is set on my Computer/properties.
Step 2: Install a Java compiler.
It is recommended to use IBM's jikes, an efficient Java compiler for open source. Jikes's homepage is in
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
After downloading, extract a jikes.exe and place it in the directory of any 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");
}
}
and then compile
Jikes Hello.java
If the hello.class is generated, it can be used.
Step 3. Install a JSP Container.
The use of Jakarta Tomcat 3.2.1 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 Jakarta-tomcat-3.2.1.zip this file
If you are installing under Windows nt/2000, there is also a jk_nt_service.zip in the win32/i386 directory.
After downloading, let's say it's under C:\tomcat.
Then you need to set an environment variable
Tomcat=c:\tomcat
To enable Tomcat to use Jikes, you need to do a little hack, as follows:
Add the Parser.jar,jaxp.jar,webserver.jar under the Tomcat's Lib directory to the environment variable CLASSPATH to take effect and perform the following steps:
CD \tomcat\src\org\apache\tomcat\context
Edit the file Webxmlreader.java to
Sw.addinitparam ("Jspcompilerplugin", "Org.apache.jasper.compiler.JikesJavaCompiler");
Before the comments are removed
and then compile
Jikes Webxmlreader.java
Create a temp directory and use the Jar tool (available from JDK) to extract the Webserver.jar from Tomcat's lib directory
mkdir T
CD T
Jar XVF ... \webserver.jar
Replace the Webxmlreader*.class under Org\apache\tomcat\context with the webxmlreader*.class that you just compiled the build
Then repackage:
Jar CF Webserver.jar.
Replace the Tomcat Webserver.jar with the new Webserver.jar
Edit the Web.xml in Tomcat's conf directory to
<!--uncomment the following to use Jikes for JSP compilation
<init-param>
<param-name>jspCompilerPlugin</param-name>
<param-value>org.apache.jasper.compiler.JikesJavaCompiler</param-value>
</init-param>
-->
Outside of the comment.
Edit the Tomcat.bat in Tomcat's Bin directory and replace all Tools.jar with Rt.jar
Start Tomcat and run the Startup.bat in the bin directory.
Use the browser to do the test, access
http://localhost:8080
If the JSP and Servlet examples are compiled and run, Tomcat can be used.
Stop Tomcat with Shutdown.bat
Under Windows nt/2000, you can install Tomcat as a service, as follows:
Copy the wrapper.properties from Tomcat's conf directory and edit it. Put two of these variables
Wrapper.tomcat_home
Wrapper.java_home
Set the installation path for TOMCAT and JRE individually, replacing all tools.jar with Rt.jar.
And then run
Jk_nt_service-i Tomcat wrapper.properties
Where Tomcat is the name of the service we have installed.
Start the Tomcat service in the Control Panel. After the Tomcat service is set up for manual startup, you can modify the properties of the Tomcat service to make it automatically start.
Remove Tomcat Service by:
Jk_nt_service-r Tomcat
Step 4. Installs a taglib that supports XSLT.
XSL Taglib in XSLT is recommended for use in Jakarta taglibs
Its page in http://jakarta.apache.org/taglibs/doc/xsl-doc/intro.html
Download the snapshot of the XSL Taglib from this page. You can also download the full range of Jakarta Taglibs,jakarta Taglibs, but here we are using only the XSL Taglib.
After downloading, unzip the Xsl-examples.war and Xsl-doc.war these two files into Tomcat's WebApps directory, and then restart Tomcat. Using Browser access
http://localhost:8080/xsl-examples/
The apply.jsp on the Run page, if there is no error, shows a page with many tables, the XSL Taglib can be used.
The XSL Taglib documentation is also installed in the
http://localhost:8080/xsl-doc/
You can start with this example and begin writing your own XML handlers step-by-step. For example, you can add a new context to Tomcat's server.xml.
<context path= "/jspxml"
Docbase= "Path-to-your-work-directory"
Crosscontext= "false"
debug= "0"