JSTL XML <x:param> Tag


The <x:param> tag is used along with the transform tag to set a parameter in the XSLT stylesheet


The <x:param> tag has following attributes:

AttributeDescription RequiredDefault
nameName of the XSLT parameter to setYesBody
valueValue of the XSLT parameter to setNoNone


Consider the following XSLT stylesheet style.xsl. Note the usage of <xsl:param...> tag and a variable {$bgColor}:

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

<xsl:output method="html" indent="yes"/>
<xsl:param name="bgColor"/>

<xsl:template match="/">

<xsl:template match="books">
  <table border="1" width="50%" bgColor="{$bgColor}">
    <xsl:for-each select="book">
          <i><xsl:value-of select="name"/></i>
          <xsl:value-of select="author"/>
          <xsl:value-of select="price"/>

Now consider the following JSP file where we define the value of bgColor using <x:param> tag inside <x:transform> tag:

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

  <title>JSTL x:transform Tags</title>
<h3>Books Info:</h3>
<c:set var="xmltext">
      <name>Padam History</name>
      <name>Great Mistry</name>

<c:import url="http://localhost:8080/style.xsl" var="xslt"/>
<x:transform xml="${xmltext}" xslt="${xslt}">
   <x:param name="bgColor" value="grey"/>


This would produce following result:

Books Info:

Padam HistoryZARA100
Great MistryNUHA2000