Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
Use of tag of JSTL 
 

In this section we will learn how to use tag of Xml tag library of Jstl. This tag is used to transform the specified xml document.

 

Use of <x:transform> tag of JSTL

                         

In this section we will learn how to use <x:parse> tag of  Xml tag library of Jstl. This tag is used to transform the specified xml document. With the use of this tag we can display data from xml document in a format that is already defined in .xslt file.

 

 

 

 

 

 

Standard Syntax : <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>

 Attributes: 
    var  Name of the variable used to store parsed xml content.
   result  Result object that capture the result after transformation.
   scope  Defines scope of the defined variable in var attribute.
    xml  This is deprecated attribute, now we are using 'doc' attribute.
xmlSystemId  This is deprecated attribute, used with attribute 'xml'.
doc  Source xml document to be transformed.
docSystemId  URI of the xml document.
xslt  javax.xml.transform.Source Transformation stylesheet.
xsltSystemId  URI of the xslt document.

transform_xmlJstlTag.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<c:import var="xml" url="employee.xml" />
<c:import var="xsl" url="employee.xsl" />

<x:transform xml="${xml}" xslt="${xsl}" />

employee.xml

<?xml version="1.0" encoding="UTF-8"?>
<org>
    <company>
        <emp>
            <name>Ravi Kant</name>
            <designation>Sr. Sofware developer</designation>
            <age>28</age>
        </emp>
        <emp>
            <name>Suman Saurabh</name>
            <designation>Sr Graphics Designer</designation>
            <age>27</age>
        </emp>
    </company>
    <company>
    <emp>
        <name>Vinod Kumar</name>
        <designation>Sr. Java Programmer</designation>
        <age>27</age>
    </emp>
    <emp>
        <name>Mr. Santosh</name>
        <designation>Sr. Flash Programmer</designation>
        <age>25</age>
    </emp></company>
</org>

employee.xsl

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:param name="doc"/>
    <xsl:template match="/">
        <html>
            <body>
                <h2>Company's Employee detail</h2>
                <table border="1">
                    <tr>
                        <th align="left">name
                        </th>
                        <th align="left">designation
                        </th>
                        <th align="left">age
                        </th>
                    </tr>
                    <xsl:for-each select="org/company/emp">
                        <tr>
                            <td>
                                <xsl:value-of select="name"/>
                            </td>
                            <td>
                                <xsl:value-of select="designation"/>
                            </td>
                            <td>
                                <xsl:value-of select="age"/>
                            </td>
                        </tr>
                    </xsl:for-each>
                </table>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>

Output :



Download Source Code

                         

» View all related tutorials
Related Tags: c xml library file files stl orm ant form io user sed jstl tag parameter transform this js for add

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.