Java Tutorial/JSTL/XML Transformation
Pass Parameter to XML Transformation
<source lang="java">
<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.ru/jstl/xml" prefix="x" %> <c:import var="xml" url="students.xml" /> <c:import var="xslt" url="transformparam.xsl" /> <x:transform xml="${xml}" xslt="${xslt}"> <x:param name="bgColor" value="blue"/> </x:transform></source>
Transform XML Data using JSTL
<source lang="java">
<%@taglib prefix="c" uri="http://java.sun.ru/jstl/core" %> <%@taglib prefix="x" uri="http://java.sun.ru/jstl/xml" %> <c:set var="xml">
<paragraph> This document uses <bold>unusual</bold> markup, which we want to replace with <bold>HTML</bold>. </paragraph>
</c:set> <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">
<xsl:apply-templates/>
</xsl:template> <xsl:template match="bold"> <xsl:value-of select="."/> </xsl:template> </xsl:stylesheet>
</c:set> <x:transform xml="${xml}" xslt="${xsl}"/></source>