How to build an XML development environment _XML/RSS

Source: Internet
Author: User
Tags documentation html page win32 wrapper xml parser xsl xslt

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"
Reloadable= "true" >
</Context>
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: http://java.sun.com/products/jsp/pdf/JSPXML.pdf
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 xml.apache.org 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: http://developerlife.com


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: http://www.w3.org/TR/WD-xsl, and Mozilla-supported XSLT is the official version of XSLT. namely: Http://www.w3.org/1999/XSL/Transform.
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:http://www.mozilla.org/releases/from 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: http://www.mozilla.org/projects/xslt/
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.
http://www.xmlspy.com/
2. Editml Pro: Another XML editor with a full function comparison.
Http://www.editml.com
3. PSGML for Emacs:emacs, I don't have to say anything, right?
Http://www.lysator.liu.se/projects/about_psgml.html



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: 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 jakarta-struts-1.0-b1.zip 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
http://localhost:8080/struts-example/
Run the Mailreader program in the page, if the correct registration can be used.
Struts's documentation is also installed,
http://localhost:8080/struts-documentation/

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:
http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.1/bin/win32/i386/
You need to download mod_jk.zip 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:
http://localhost/examples/
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. :-)

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.