|
Introduction to XSL |
The XSLT Packages The XSLT APIs is defined in the following
packages:
Package |
Description |
javax.xml.transform |
Defines the
TransformerFactory
and Transfo mer
classes. These
classes are used to
get an object for
doing
transformations.
After creating a
transformer object,
its transform()
method is invoked.
This method
provides an input
(source) and output
(result). |
javax.xml.transform.dom |
Defines classes
used to create input
and output objects
from a DOM. |
javax.xml.transform.sax |
Defines classes
used to create input
from a SAX parser
and output objects
from a SAX
event handler. |
javax.xml.transform.stream |
Defines classes
used to create
input and output
objects from an
I/O stream. |
|
|
|
In this tutorial, we will convert a simple XML file
into HTML using XSLT APIs.
To develop this program, do the following steps:
1. Create an XML file
The code for the emp.xml file is given below:
<?xml version = “1.0” ?>
<Employee-Detail>
<Employee>
<Emp_Id> E-001 </Emp_Id>
<Emp_Name> Nisha </Emp_Name>
<Emp_E-mail> Nisha1@yahoo.com </
Emp_E-mail>
</Employee>
<Employee>
<Emp_Id> E-002 </Emp_Id>
<Emp_Name> Amit</Emp_Name>
<Emp_E-mail> Amit2@yahoo.com </Emp_Email>
</Employee>
<Employee>
<Emp_Id> E-003 </Emp_Id>
<Emp_Name> Deepak </Emp_Name>
<Emp_E-mail> Deepak3@yahoo.com </
Emp_E-mail>
</Employee>
</Employee-Detail> |
2. Create an XSL Stylesheet
Lets see the source code of XSL stylesheet
(emp.xsl) that provides templates to transform
the XML document:
<?xml version=”1.0" ?>
<xsl:stylesheet xmlns:xsl=”http://
www.w3.org/1999/XSL/Transform”
version=”1.0">
<xsl:output method=”html” indent=”yes”/>
|
|
|
Mar 2008 | Java Jazz Up |15 |
|
|
|
View All Topics |
All Pages of this Issue |
Pages:
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53 ,
54,
55,
56,
57,
58,
59,
Download PDF |
|
|
|
|
|
|
|
|
|