目录 搜索
JSP 基础教程 JSP 开发环境搭建 JSP 结构 JSP 生命周期 JSP 语法 JSP 指令 JSP 动作元素 JSP 隐式对象 JSP 客户端请求 JSP 服务器响应 JSP HTTP 状态码 JSP 表单处理 JSP 过滤器 JSP Cookies 处理 JSP Session JSP 文件上传 JSP 日期处理 JSP 页面重定向 JSP 点击量统计 JSP 自动刷新 JSP 发送邮件 JSP 高级教程 JSP 标准标签库(JSTL) <c:out> 标签 <c:set> 标签 <c:remove> 标签 <c:catch> 标签 <c:if> 标签 <c:choose> <c:import> 标签 <c:forEach> <c:param> 标签 <c:redirect> 标签 <fmt:formatNumber>标签 <fmt:parseNumber> 标签 <fmt:formatDate> 标签 <fmt:parseDate> 标签 <fmt:bundle> 标签 <fmt:setLocale> 标签 <fmt:setBundle> 标签 <fmt:timeZone> 标签 <fmt:setTimeZone> 标签 <fmt:message> 标签 <fmt:requestEncoding> 标签 <sql:setDataSource> 标签 <sql:query> 标签 <sql:update> 标签 <sql:param> 标签 <sql:dateParam> 标签 <sql:transaction> 标签 <x:out> 标签 <x:parse> 标签 <x:set> 标签 <x:if> 标签 <x:forEach> 标签 <x:choose> <x:transform> 标签 <x:param> 标签 fn:contains()函数 fn:containsIgnoreCase()函数 fn:endsWith()函数 fn:escapeXml()函数 fn:indexOf()函数 fn:join()函数 fn:length()函数 fn:replace()函数 fn:split()函数 fn:startsWith()函数 fn:substring()函数 fn:substringAfter()函数 fn:substringBefore()函数 fn:toLowerCase()函数 fn:toUpperCase()函数 fn:trim()函数 JSP 连接数据库 JSP XML 数据处理 JSP JavaBean JSP 自定义标签 JSP 表达式语言 JSP 异常处理 JSP 调试 JSP 国际化
文字

<x:transform> 标签


<x:transform>标签在XML文档中应用XSL。


属性

<x:transform>标签有如下属性:

属性 描述 是否必要 默认值
doc 源XML文档 Body
docSystemId 源XML文档的URI
xslt XSLT 样式表
xsltSystemId 源XSLT文档的URI
result 接收转换结果的对象 Print to page
var 代表被转换的XML文档的变量 Print to page
scope var属性的作用域

实例演示

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:template match="/">
  <html>
  <body>
   <xsl:apply-templates/>
  </body>
  </html>
</xsl:template>

<xsl:template match="books">
  <table border="1" width="100%">
    <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>

main.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 标签</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}"/>

</body>
</html>

运行结果如下:

x-transform

关于我们 联系我们 留言板

手册网

上一篇: 下一篇: