XML transformation : XML « JSP « Java






XML transformation

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

<c:import url="http://localhost:8080/home/build.xml" var="buildXml" />
<c:import url="/WEB-INF/xslt/myTrans.xsl" var="xslt" />
<x:transform xml="${buildXml}" xslt="${xslt}" />

//myTrans.xsl


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output method="html"/>

<xsl:template match="/">
    <html><head><title>List of build.xml targets
    </title></head><body bgcolor="white"><h2>Build.xml targets</h2>
    <xsl:apply-templates />
    </body></html>
</xsl:template>

<xsl:template match="/project">
<dl>
    <xsl:for-each select="./target">
    <dt><b><xsl:value-of select="@name" /></b>&#xA0;</dt>
            <xsl:if test="@depends">
            <dd>depends=<xsl:value-of select="@depends" />&#xA0;</dd></xsl:if>        
    </xsl:for-each><!--end for-each contact -->
</dl>
</xsl:template>

        
<xsl:template match="text()">
    <xsl:value-of select="normalize-space()" />
</xsl:template>
    
    
</xsl:stylesheet>

           
       








Related examples in the same category

1.Using the Core XML tags
2.Performing XSL Transformations
3.JSP in pure XML generating conforming XHTML
4.XSLT In JSP
5.XSLT in JSP 2
6.JSP Parsing using the DOM
7.JSP Parsing using JDOM
8.JSP Parsing using the DOM and JSTL
9.JSP and SAX
10.JSP Displaying a Subset in XML
11.JSP XML and XSLT transform
12.JSP List of data in the XML document
13.Deal With XML In JSP