
- JSP 基礎教程
- JSP - 首頁
- JSP - 概述
- JSP - 環境設定
- JSP - 架構
- JSP - 生命週期
- JSP - 語法
- JSP - 指令
- JSP - 動作
- JSP - 隱式物件
- JSP - 客戶端請求
- JSP - 伺服器響應
- JSP - HTTP 狀態碼
- JSP - 表單處理
- JSP - 編寫過濾器
- JSP - 處理 Cookie
- JSP - 會話跟蹤
- JSP - 檔案上傳
- JSP - 處理日期
- JSP - 頁面重定向
- JSP - 訪問計數器
- JSP - 自動重新整理
- JSP - 傳送郵件
- 高階 JSP 教程
- JSP - 標準標籤庫
- JSP - 資料庫訪問
- JSP - XML 資料
- JSP - JavaBean
- JSP - 自定義標籤
- JSP - 表示式語言
- JSP - 異常處理
- JSP - 除錯
- JSP - 安全性
- JSP - 國際化
- JSP 有用資源
- JSP - 問答
- JSP - 快速指南
- JSP - 有用資源
- JSP - 討論
JSTL - XML <x:transform> 標籤
<x:transform> 標籤對 XML 文件應用 XSL 轉換。
屬性
<x:transform> 標籤具有以下屬性:
屬性 | 描述 | 必需 | 預設值 |
---|---|---|---|
doc | XSLT 轉換的源 XML 文件 | 否 | 主體 |
docSystemId | 原始 XML 文件的 URI | 否 | 無 |
xslt | 提供轉換指令的 XSLT 樣式表 | 是 | 無 |
xsltSystemId | 原始 XSLT 文件的 URI | 否 | 無 |
result | 接收轉換結果的結果物件 | 否 | 列印到頁面 |
var | 設定為轉換後 XML 文件的變數 | 否 | 列印到頁面 |
scope | 公開轉換結果的變數的作用域 | 否 | 無 |
示例
考慮以下 XSLT 樣式表 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> </xsl:stylesheet>
現在考慮以下 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 = "https://:8080/style.xsl" var = "xslt"/> <x:transform xml = "${xmltext}" xslt = "${xslt}"/> </body> </html>
您將收到以下結果:
Books Info:
Padam History
ZARA
100 Great Mistry
NUHA
2000
jsp_standard_tag_library.htm
廣告