XSLT current() 함수
정의와 사용법
current() 함수는 단순히 현재 노드를 포함하는 노드 셋을 반환합니다. 일반적으로 현재 노드와 컨텍스트 노드는 같습니다.
<xsl:value-of select="current()"/>
равно
<xsl:value-of select="."/>
그러나, 다른 점이 있습니다. 아래의 XPath 표현식을 보세요: "catalog/cd". 표현식은 현재 노드의 <catalog> 자식 노드를 선택한 후, <catalog> 노드의 <cd> 자식 노드를 선택합니다. 이는 계산의 각 단계에서 "." 의 의미가 다르다는 것을 의미합니다.
아래의 행:
<xsl:apply-templates select="//cd[@title=current()/@ref]"/>
title 속성의 값이 현재 노드의 ref 속성의 값과 같은 모든 cd 요소를 처리합니다.
이와 다른 점은:
<xsl:apply-templates select="//cd[@title=./@ref]"/>
이는 title 속성과 ref 속성이 같은 값을 가진 모든 cd 요소를 처리합니다.
문법
node-set current()
예제
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <xsl:for-each select="catalog/cd/artist"> 현재 노드: <xsl:value-of select=""}current()"/> <br /> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>