속성
| 속성 | 설명 | 필수 | 기본값 |
|---|---|---|---|
| 문서 | XSLT 변환을 위한 소스 XML 문서 | 아니요 | 본문 |
| docSystemId | 원본 XML 문서의 URI | 아니요 | 없음 |
| xslt | 변환 지침을 제공하는 XSLT 스타일시트 | 예 | 없음 |
| xsltSystemId | 원본 XSLT 문서의 URI | 아니요 | 없음 |
| 결과 | 변환 결과를 받아들이는 결과 개체 | 아니요 | 페이지로 인쇄 |
| var | 변환된 XML 문서에 설정되는 변수 | 아니요 | 페이지로 인쇄 |
| 범위 | 변환 결과를 노출할 변수의 범위 | 아니요 | 없음 |
예시
다음 XSLT 스타일시트 style.xsl을 고려하세요. -
<?xml version = "1.0"?> <xsl:stylesheet xmlns:xsl = "https://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 = "https://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix = "x" uri = "https://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://localhost:8080/style.xsl" var = "xslt"/>
<x:transform xml = "${xmltext}" xslt = "${xslt}"/>
</body>
</html> 다음 결과를 받게 됩니다 -
도서 정보
| 빠담 역사 자라 | 100 |
| 그레이트 미스트리 누하 | 2000 |