We know that XML XSLT can output directly to the XML browser, such as IE 5.0 or more, but we have to consider that there are many browsers to support XML, in which case we need to be on the server. Convert to HTML output to the browser, this temporary transition method is probably to use within a period of time.
With JSP plus the TabLib ID library, we can complete this conversion.
The famous Open Source Project Group Jakarta.apache.org has this feature TANGLIB: http://jakarta.apache.org/taglibs/doc/xsl-doc/intro.html
According to the Jakarta configuration method, it is a bit cumbersome, you need to modify or define web.xml. I have been exploited, using the following quite simple approach, you can make JSP to run the XSL this identity library.
XSL ID libraries have three key packages:
Xerces.jar can get in http://xml.apache.org/
Xalan.jar can get in http://xml.apache.org/
Xsl.jar gets from http://jakarta.apache.org/taglibs/doc/xsl-doc/intro.html
1. Place these three packages in the Tomcat's CommON / lib directory, or put them directly into the ClassPath environment.
2. Call the logos library in JSP:
The original JAKARTA recommended method is:
<% @ Taglib Uri = "http://jakarta.apache.org/taglibs/xsl-1.0" prefix = "xsl"%>
This will need to define http://jakarta.apache.org/taglibs/xsl 1.0 points under /Web-inf/web.xml. Such as:
taglib>
Although this approach is very standard, if your container has been using Tomcat, it will not have to.
Our approach is:
<% @ Taglib Uri = "xsl.jar" prefix = "xsl"%>
As an example with Apply.jsp comes with Jakarta's XSL Taglib, let's take a look at the relationship between JSP XML XSLT:
Apply.jsp
<% @ Taglib Uri = "xsl.jar" prefix = "xsl"%>
hEAD>
The following is shown in the four combinations of XML XSLT of JSP:
Using the Apply method below, combine the already existing Employees.xml and Employeelist.xsl
The following is to write XML data directly in your own Employeelist.xsl and then yourself in JSP.
Employee>
Employee>
Employee>
Employees>
xsl: apply>
The following is the way to use include, such an XSLT style can accommodate different XML files.
xsl: apply>
The following is the use of the Import method, imported XML file p> in page-scope (similar to scope = "page")
body>
In the above program, four JSP combined XML XSLT methods are shown, which can basically meet our needs. Note The above XML file path is "/ xml /", which is an absolute path to the Tomcat container.
Let's take a look at Employeelist.xsl and Employees.xml content:
EmployeeList.xsl is similar to CSS in HTML, mainly to define data display mode in XML:
XML Version = "1.0"?>