<X : PARAM> 태그
<X : PARAM> 태그와 <X : 변환> 태그는 XSLT 스타일 시트에 대한 매개 변수를 설정하기 위해 함께 사용됩니다.
구문
<x:param name="<string>" value="<string>"/>
재산
<X : PARAM> 태그는 다음과 같은 특성이 있습니다 :
재산 | 기술 | 필요한 경우 | 디폴트 값 |
---|---|---|---|
이름 | XSLT 매개 변수 이름 | 그것은 인 | 몸 |
값 | XSLT 매개 변수 값 | 아니 | 아니 |
예를 들면 데모
PARAM ... 레이블 {$ bgColor가} 변수를 다음 XSL을 사용하여 다음과 같이 style.xsl 파일의 코드는 다음과 같습니다
<?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="/"> <html> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="books"> <table border="1" width="50%" bgColor="{$bgColor}"> <xsl:for-each select="book"> <tr> <td> <i><xsl:value-of select="name"/></i> </td> <td> <xsl:value-of select="author"/> </td> <td> <xsl:value-of select="price"/> </td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet>
X에 다음과 같이 mian.jsp 파일의 코드는 다음과 같습니다 PARAM 태그 : 사용이 태그를 변환 X :
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %> <html> <head> <title>JSTL x:param 标签</title> </head> <body> <h3>Books Info:</h3> <c:set var="xmltext"> <books> <book> <name>Padam History</name> <author>ZARA</author> <price>100</price> </book> <book> <name>Great Mistry</name> <author>NUHA</author> <price>2000</price> </book> </books> </c:set> <c:import url="http://localhost:8080/style.xsl" var="xslt"/> <x:transform xml="${xmltext}" xslt="${xslt}"> <x:param name="bgColor" value="grey"/> </x:transform> </body> </html>
결과는 다음과 같습니다 :