Jsp-jstl-xml-param-tag
提供:Dev Guides
JSTL-XML <x:param>タグ
*<x:param>* タグは、XSLTスタイルシートでパラメーターを設定するために変換タグと一緒に使用されます
属性
*<x:param>* タグには次の属性があります-
Attribute | Description | Required | Default |
---|---|---|---|
name | Name of the XSLT parameter to set | Yes | Body |
Value | Value of the XSLT parameter to set | No | None |
例
次のXSLTスタイルシートstyle.xslを検討してください。 <xsl:param …> タグと変数 \ {$ 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 = "/">
<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:transform>* タグ内の *<x:param>* タグを使用して *bgColor* の値を定義する次のJSPファイルを検討してください-
<%@ 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:transform Tags</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>
次の結果が表示されます-
Books Info:
Padam History | ZARA | 100 |
Great Mistry | NUHA | 2000 |