JSP combined with XML + XSLT to convert output to HTML

Source: Internet
Author: User

We know that XML + XSLT can be directly output to browsers that support XML, such as IE 5.0 or later. However, we also need to consider that many Browsers Do not directly support XML. In this case, we need to convert to html output to the browser on the server. I am afraid this temporary transition method will be used for a while. bhd webmaster Information
Bhd webmaster Information
Using Jsp with tablib to identify the library, we can complete this conversion. Bhd webmaster Information
Bhd webmaster Information
Tanglib: http://jakarta.org/taglibs/doc/developer-doc/intro.html
Bhd webmaster Information
According to the configuration method of jakarta, it is a little complicated. You need to modify or define Web. xml. After self-exploration, you can use the following simple methods to make Jsp successfully run the XSL identity library. Bhd webmaster Information
Bhd webmaster Information
The xsl identification library has three key packages: bhd webmaster Information
Bhd webmaster Information
Xerces. jar can get bhd webmaster information at http://xml.apache.org/
Xalan. jar can get bhd webmaster information at http://xml.apache.org/
Xsl. jar received bhdwebmaster information from http://jakarta.apache.org/taglibs/doc/developer-doc/intro.html
1. Place the three packages in the common/lib directory of Tomcat, or directly put them in the Classpath environment. Bhd webmaster Information
Bhd webmaster Information
2. Call the identification library in JSP: bhd webmaster Information
Bhd webmaster Information
The original method recommended by Jakarta is: bhd webmaster Information
Bhd webmaster Information
<% @ Taglib uri = "http://jakarta.apache.org/taglibs/xsl-1.0" prefix = "xsl" %> bhd webmaster Information
Bhd webmaster Information
Bhd webmaster Information
This requires defining http://jakarta.apache.org/taglibs/xsl-1.0in/WEB-INF/web. xml. For example, bhd webmaster Information
Bhd webmaster Information
<Taglib> bhd webmaster Information
<Taglib-uri> http://jakarta.apache.org/taglibs/xsl-1.0 </taglib-uri> bhd webmaster Information
<Taglib-location>/WEB-INF/xsl. tld </taglib-location> bhd webmaster Information
</Taglib> bhd webmaster Information
Bhd webmaster Information
Bhd webmaster Information
Although this method is very standard, if your container has been using tomcat, it is completely unnecessary. Bhd webmaster Information
Bhd webmaster Information
Our practice is: bhd webmaster Information
Bhd webmaster Information
<% @ Taglib uri = "xsl. jar" prefix = "xsl" %> bhd webmaster Information
Bhd webmaster Information
Bhd webmaster Information
Take Apply. jsp included in XSL taglib of Jakarta as an example to understand the relationship between Jsp xml xslt and bhd webmaster information.
Bhd webmaster Information
Apply. jspbhd webmaster Information
Bhd webmaster Information
<% @ Taglib uri = "xsl. jar" prefix = "xsl" %> bhd webmaster Information
<Html> bhd webmaster Information
<Head> bhd webmaster Information
<Title> Employee List </title> bhd webmaster Information
</Head> bhd webmaster Information
<Body bgcolor = "white"> bhd webmaster Information
Bhd webmaster Information
<P> The following shows four methods for combining xml xslt in Jsp: bhd webmaster information.
<P> the following uses the apply method to combine existing employees. xml and employeeList. xsl with bhd webmaster information.
Bhd webmaster Information
<Xsl: apply xml = "/xml/employees. xml" xsl = "/xml/employeeList. xsl"/> bhd webmaster Information
<Hr> bhd webmaster Information
Bhd webmaster Information
Bhd webmaster Information
<P> The following describes how to use employeeList. xsl to directly write XML data in Jsp. bhd webmaster information.
Bhd webmaster Information
Bhd webmaster Information
<Xsl: apply xsl = "/xml/employeeList. xsl"> bhd webmaster Information
<? Xml version = "1.0" encoding = "ISO-8859-1"?> Bhd webmaster Information
<Employees> bhd webmaster Information

  • Three pages in total:
  • Previous Page
  • 1
  • 2
  • 3
  • Next Page

Related Article

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.