How to create an XML development environment

Source: Internet
Author: User
Tags xsl xslt
The best way to learn xml is to start with simple development, practice boldly, and step by step. The beauty of XML can only be deeply understood in the development process. XML cannot be learned without development. Therefore, to learn XML, you must first establish an XML development environment. I will introduce how to build a java-based XML development environment. [Guide] the best way to learn xml is to start with simple development, practice boldly, and step by step. The beauty of XML can only be deeply 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 introduce it to you.

The best way to learn xml is to start with simple development, practice boldly, and step by step. The beauty of XML can only be deeply understood in the development process. XML cannot be learned without development. Therefore, to learn XML, you must first establish an XML development environment. I will introduce how to build a java-based XML development environment. Because I cannot 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 commercial re-release. JRE can also be downloaded and used 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 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
We recommend that you use Sun's JRE 1.3. you can download it from here:
#
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. for Windows NT/2000, set it 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
#
The latest version is 1.1.3. you can download it from here:
#
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.

Edit a simple hello world program and try it:

// hello.javapublic class hello {public static void main(String [] args) {System.out.PRint("hello, world!\n");}}

Then compile
Jikes hello. java

If hello. class is generated, it can be used.


Step 3. Install a JSP Container.
We recommend that you use Tomcat 3.2.1 of Jakarta. Tomcat 3.2.1 can be downloaded from here:
#
You need to download the jakarta-tomcat-3.2.1.zip file
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 use jikes, you need to do a little bit of hack as follows:
Add parser. jar, jaxp. jar, and webserver. jar in the lib directory of tomcat to the environment variable CLASSPATH, and perform the following steps for them to take effect:
Cd \ tomcat \ src \ org \ apache \ tomcat \ context
Edit the file WebXmlReader. java and set

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


Remove the comment before

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
Replace WebXmlReader *. class under org \ apache \ tomcat \ context with the WebXmlReader *. class just compiled.
Then re-package:
Jar cf webserver. jar.
Use the new webserver. jar to replace Tomcat's webserver. jar

Edit web. xml in the conf directory of Tomcat

 

Remove the comment.

Edit Tomcat. bat in the bin directory of tomcat and replace all tools. jar with rt. jar.
Start tomcat and run startup. bat in the bin directory.
Use a browser to test and access
#: 8080
If JSP and Servlet examples can be compiled and run, Tomcat can be used.
Stop Tomcat with shutdown. bat

In Windows NT/2000, you can install tomcat as a service by using the following methods:
Copy wrapper. properties in the conf directory of Tomcat and edit it. Set the two variables
Wrapper. tomcat_home
Wrapper. java_home
Set the installation path to TOMCAT and JRE respectively, and replace all tools. jar with rt. jar.
Then run
Jk_nt_service-I Tomcat wrapper. properties
Tomcat is the name of the service we have installed.
Go to the control panel and start Tomcat service. After Tomcat service is installed, set it to manual start. you can modify the attributes of Tomcat service to make it automatically start.

To delete a Tomcat service:
Jk_nt_service-R Tomcat


Step 4. Install a taglib that supports XSLT.
We recommend that you use the XSL Taglib for XSLT in Jakarta Taglibs.
The page is on #
Download the snapshot of XSL Taglib from this page. You can also download all Jakarta Taglibs. Jakarta Taglibs has a wide range, but here we only need to use the XSL Taglib.

Decompress the package, copy the xsl-examples.war and xsl-doc.war files to the webapps directory of Tomcat, and restart Tomcat. Access through a browser
#: 8080/xsl-examples/
Run Apply. jsp on the page. If no error occurs, a page with many tables is displayed, and XSL Taglib can be used.
The documentation for XSL Taglib is also installed.
#: 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.

 

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 for reference.

For details about how to use JSP for XML development, refer to Sun's whitepaper, :#
This is basically 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 used by Tomcat and xml.apache.org used by XSL Taglib. JAXP includes two files: parser. jar and jaxp. jar. Xerces has only one file, xerces. jar, which can be found in the Tomcat directory.
Xerecs XML Parser is recommended because it currently supports XML Schema and is open source software. However, this is entirely out of personal preferences, and Sun's XML Parser is also outstanding. Decide which XML Parser to use and add the file to CLASSPATH. But do not use two XML Parser at the same time. After CLASSPATH takes effect, you can use the JDOM and SAX APIs in your Java program to process XML files.

Examples of the applicable scenarios and usage of JDOM and SAX can be found here :#


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 to HTML format and send it to the Browser, so you can actually use any Browser you like. However, installing a browser that supports XSLT makes it easier for us to learn. Although we now need to do XSLT on the Server side, we can even skip this step even after the browsers that support XSLT become popular in the future, simply send the XML and XSL files to the browser. This can greatly reduce the burden on the Server, because it is not easy to do XSLT.

Mozilla 0.8 is recommended. Speaking of this, you may have to ask again, why not use IE 4/5? Can IE 4/5 be used for XSLT? In addition to my personal preferences, I can cite three reasons for using Mozilla:
First, Mozilla supports a newer XSLT version than IE 4/5. The XSLT supported by IE 4/5 is not a formal version, but a draft. That is: #. Mozilla supports the official version of XSLT. That is :#.
Secondly, XML applications in Mozilla include not only XSLT, but also RDF, XUL, SVG, and MathML. Therefore, Mozilla's support for XML exceeds IE 4/5 in both breadth and depth.
The authors of the third xml faq highly praised Mozilla and believed that Mozilla's support for XML is much more robust than IE 4/5.

Okay. now let's go to the topic. how can we make Mozilla 0.8 support XSLT?
First, download Mozilla 0.8 from here :#
The latest version is Version 0.8.1. However, this version cannot run after it is installed with a module that supports XSLT. Therefore, you can only use Version 0.8, which is earlier but slower.
If you do not want to use other functions such as SVG/MathML, the most convenient method is to install the. exe file.
After the installation is complete, start Mozilla and visit this page :#
There is an Install button on the page. click this button to Install the TransforMiiX module that implements the XSLT function.
Restart Mozilla to access the page mentioned above. Click the link of simple example above. If the result is the same as that displayed by clicking the look like link, your Mozilla will be able to support XSLT.

For details about how to configure Mozilla 0.8 to support Java Plug-in, refer to another post I posted in XML: Mozilla-based XML client solution.


Step 7. Install an XML file editor.
This step is not necessary. Have you heard that there are still people using vi for HTML pages? I have met such a person, that is, Mr Yu Mingyu. On the instructor's personal homepage, there is a striking saying: Just vim it! In fact, you can use any of your favorite editors to edit XML files. but to make it easier for those friends who are used to using the WYSIWYG editor, I recommend several better XML editors:
1. XML Spy: A fully functional XML editor that can be downloaded in a trial version.
#
2. EditML Pro: another fully functional XML editor.
#
3. PSGML for Emacs: Emacs. I don't need to say anything?
#



Here, we will introduce some other things for the sake of the icing on the cake. using this knowledge, we can build a more powerful development environment.

Step 8. Install a better JSP Framework
Struts is recommended. Struts is a subproject of the Jakarta project. it aims to develop a JSP Framework based on the MVC design pattern. Development within the Struts framework can effectively separate the presentation layer and implementation layer of Web applications and improve code reusability. The development based on the MVC design pattern is also called the Model 2 development pattern. The project is nearing completion. The latest version is 1.0-beta-1.

For more information about the MVC design mode, see the design mode published by the mechanical industry press. For the usage of Struts, refer to the Struts user guide I translated. in this article :#

Download Jakarta Struts from here:
#
You need to download the jakarta-struts-1.0-b1.zip file.
Decompress it, copy the struts-example.war, struts-documentation.war files to the webapps directory of Tomcat, and restart Tomcat. Access through a browser
#: 8080/struts-example/
Run the MailReader program on the page. you can use it if it can be correctly registered.
The Struts document is also installed.
#: 8080/struts-documentation/

For details about how to use Struts in your development Directory, refer to the document in Struts. Java has some discussions about Struts, which can be found through the search function of the Forum.


Step 9. Establish a connection with Apache
This is an old growth Talk. I will introduce the simplest method to use mod_jk to establish a connection with Apache.
Suppose you have installed Apache. download mod_jk from here:
#
You need to download the mod_jk.zip file.
Decompress the package to obtain a mod_jk.dll and copy it to the modules directory under the Apache installation directory.
Modify the Apache configuration file httpd. conf and add the following two lines:

Include C:/tomcat/conf/mod_jk.conf-autoJkMount /*.do ajp12

"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 access this page:
#
If jsp and servlet directories can be listed, the connection between Tomcat and Apache will be established.

The preceding figure shows how to create an XML development environment. For more information, see The PHP Chinese website (www.php1.cn )!

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.