Source Code : XSLT in JSP 2
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
XSLT in JSP 2
/*
Java, XML, and Web Services Bible
Mike Jasnowski
ISBN: 0-7645-4847-6
*/
<%@ page contentType="image/svg-xml" %>
<%@ page import="org.xml.sax.*" %>
<%@ page import="org.apache.xalan.xslt.*" %>
<%@ page import="java.io.*" %>
<%
try {
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
processor.process(new XSLTInputSource("games.xml"),
new XSLTInputSource("games.xsl"),
new XSLTResultTarget(bos));
out.println(bos);
} catch (Exception ex) {
out.println(ex);
}
%>
<?xml version="1.0"?>
<games>
<game genre="rpg">XML Invaders</game>
<game genre="rpg">A Node in the XPath</game>
<game genre="rpg">XPath Racers</game>
</games>
//games.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:template match="/">
<svg width="200" height="200">
<g>
<xsl:for-each select="games/game">
<text x="10" y="{number(10)*position()}">
<xsl:value-of select="text()"/>
</text>
</xsl:for-each>
</g>
</svg>
</xsl:template>
</xsl:stylesheet>
Thank with us