The beginning of XML learning

Source: Internet
Author: User
Tags add html page variables version variable win32 wrapper access
XML learning XML is the best way to start from the simple development, bold practice, step-by-step. 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:
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.
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
The latest version is 1.1.3, which can be downloaded from here:
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:
public class Hello {
public static void Main (String [] args) {
System.out.print ("Hello, world!\n");

and then compile

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:
You need to download this file
If you are installing under Windows nt/2000, there is also a in the win32/i386 directory.

After downloading, let's say it's under C:\tomcat.
Then you need to set an environment variable

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 to
Sw.addinitparam ("Jspcompilerplugin", "Org.apache.jasper.compiler.JikesJavaCompiler");
Before the comments are removed

and then compile

Create a temp directory and use the Jar tool (available from JDK) to extract the Webserver.jar from Tomcat's lib directory
mkdir 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
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
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 from Tomcat's conf directory and edit it. Put two of these variables
Set the installation path for TOMCAT and JRE individually, replacing all tools.jar with Rt.jar.
And then run
Jk_nt_service-i Tomcat
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
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
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

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"
Reloadable= "true" >
One of the path-to-your-work-directory is your development directory. Copy the contents of Tomcat's Webapps/xsl-examples directory to your development directory, and start writing your own XML handlers as a reference to this program.

about how to use JSP to do XML development can refer to Sun whitepaper, in:
That's basically what I told you about this method.

Step 5. Installs an XML Parser.
Having done steps 3 and 4, you have two available XML Parser, which is the Xerces of the used by the Sun JAXP and XSL Taglib that Tomcat uses. JAXP includes two files Parser.jar and jaxp.jar,xerces only one file Xerces.jar, these files can be found from the Tomcat directory.
It is recommended that you use the Xerecs XML Parser, because it can now support the XML Schema, and it is the open source software. But it's all about personal preference, and Sun's XML Parser is excellent. Decide which XML Parser to use and then add their files to the CLASSPATH. But do not use two XML Parser at the same time. Once the CLASSPATH is in effect, you can use the JDOM and SAX APIs in your Java program to process XML files.

Examples of the applications and usages of JDOM and SAX can be found here:

Step 6. Installs 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 to HTML format and send it to Browser, so you can actually use any browser you like. But installing a browser that supports XSLT can facilitate our learning. Although we now need to do XSLT on the server side, but in the future browsers that support XSLT become popular, we can even skip this step by sending XML and XSL files to the browser. This can greatly reduce the burden on the server side, because doing XSLT is not an easy task.

The use of Mozilla 0.8 is recommended. Speaking of which, you may ask again, why not use IE 4/5? IE 4/5 not also can do XSLT? In addition to my personal preferences, I can cite 3 reasons to use Mozilla:
First, Mozilla supports an XSLT version that is newer than IE 4/5, and the IE 4/5-supported XSLT is not a formal version but a draft. That is:, and Mozilla-supported XSLT is the official version of XSLT. namely: Http://
Second, the XML application in Mozilla includes not only XSLT, but also rdf,xul,svg,mathml and so on, so Mozilla's support for XML goes beyond IE 4/5 in breadth and depth.
The author of the third XML FAQ has added to Mozilla's view that Mozilla's support for XML is much better robust than IE 4/5.

OK, so much, now turn to the point, how to make Mozilla 0.8 support XSLT?
First, download Mozilla 0.8: here
The latest is the 0.8.1 version, but this version does not run after installing the XSLT-enabled module, so it's only going to use the older but slower version 0.8.
If you do not want to have other functions such as SVG/MATHML, the most convenient way is to use a good. exe file installation.
After installation, start Mozilla, visit this page:
There is a Install button on the page, and clicking this button installs the Transformiix module that implements the XSLT function.
Restart Mozilla to access the page mentioned above. Click on the simple example link above. If the results you see are the same as those seen with the click like link, then your Mozilla can already support XSLT.

For more information on how to configure the Mozilla 0.8 support Java Plug-in Please refer to my other post in the XML version: the Mozilla based XML client solution, which is not much to say here.

Step 7. Installs an editor for an XML file.
This step is more than necessary. Have you ever heard of anyone using VI as an HTML page? I have seen this kind of person, that is Yu Mingxian teacher. Lies in the teacher's personal homepage has a kind of eye-catching words: Just vim it! You can actually edit the XML file using any of your favorite editors, but for the convenience of friends who are accustomed to using the WYSIWYG editor, I recommend a few better XML editors:
1. XML Spy: A full-featured XML editor with a trial version to download.
2. Editml Pro: Another XML editor with a full function comparison.
3. PSGML for Emacs:emacs, I don't have to say anything, right?

This is just for the icing on the cake. To introduce some other knowledge, using this knowledge we can build a more powerful development environment.

Step 8. Install a better JSP Framework
It is recommended to use Struts. Struts is a subproject of the Jakarta project to develop a JSP Framework based on the MVC design pattern. The development of Struts can effectively separate the presentation layer and implementation layer of WEB application, and improve the reusability of code. Development based on MVC design pattern is the so-called Model 2 development mode. Currently the project is nearing completion and the latest version is 1.0-beta-1.

about what the MVC design pattern can refer to the book "Design Patterns" of the mechanical industry press. For the use of struts, you can refer to my translation of the Struts User Guide, in the article highlights:

Download Jakarta Struts from here:
You need to download this file.
Unzip it, and then copy the Struts-example.war,struts-documentation.war two files to Tomcat's WebApps directory, and then restart Tomcat. Using Browser access
Run the Mailreader program in the page, if the correct registration can be used.
Struts's documentation is also installed,

For information on how to use struts in your own development directory, refer to the documentation that struts brings. There are some discussions about Struts in the Java version, which can be found using the Forum's search function.

Step 9. Establish a connection with Apache
This is already the old growth talk, I introduce the easiest way to use MOD_JK to establish a connection with Apache.
Let's say you've installed Apache, download mod_jk from here:
You need to download this file.
Unzip it, get a mod_jk.dll, and copy it to the modules directory under the Apache installation directory.
To modify the Apache configuration file httpd.conf, add the following two lines:
Include C:/tomcat/conf/mod_jk.conf-auto
Jkmount/*.do AJP12
where "C:/tomcat" is the Tomcat installation directory.
Add the index.jsp to the DirectoryIndex, namely:
DirectoryIndex index.html index.jsp
If there is a comment before the ServerName, open the comment before ServerName and set it to localhost, that is:
ServerName localhost

Restart Apache to access this page:
If you can list the JSP and servlet directories, the Tomcat and Apache connections are built.

OK, say so much, actually just tidy up the house. Now that the housekeeping has been sorted out, we can start doing XML development.

Related Article

Cloud Intelligence Leading the Digital Future

Alibaba Cloud ACtivate Online Conference, Nov. 20th & 21st, 2019 (UTC+08)

Register Now >

Starter Package

SSD Cloud server and data transfer for only $2.50 a month

Get Started >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.