java left logo
java middle logo
java right logo
 


 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4095
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
JSTL - Sample XSLT transformation E-mail
User Rating: / 16
PoorBest 

JSTL provides a simple tag - <x:transform>, that should handle most of your XSLT-transformation needs. The <x:transform> tag's two most basic attributes are xml and xslt. Given a source XML document (xml) and an XSLT stylesheet (xslt), the tag's default behavior is to apply the stylesheet to the source and output the result into the page. This simple use of the <x:transform> tag accepts a source document and a stylesheet, both of which are exposed by <c:import> tags. The tag then applies the XSLT stylesheet to the document and outputs the result:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>

////////////// sets xml variable

<c:set var="xml">
  <paragraph>
    This document uses <bold>unusual</bold> markup,
    which we want to replace with <bold>HTML</bold>.
  </paragraph>
</c:set>

////////////// sets xsl variable

<c:set var="xsl">
  <?xml version="1.0"?>
  <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    
    <xsl:template match="paragraph">
      <p><xsl:apply-templates/></p>
    </xsl:template>
    
    <xsl:template match="bold">
      <b><xsl:value-of select="."/></b>
    </xsl:template>
  </xsl:stylesheet>
  
</c:set>

////////////// uses xml and xsl:

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


 Related Tips

 
< Prev   Next >
Posted by Mark van Wyk, http://www.gondwanaalive.org on Tuesday, 30 May 2006 at 4:48

For those of you who were wondering, the JSTL library includes the core, SQL, formatting and XML taglibs. I found myself searching the net for the JSTL XML taglib, when it\'s all bundeld in the jstl.jar library which simply needs to be dumped into the /WEB-INF lib directory of your web-app.


 1 
Page 1 of 1 ( 1 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.