XSLT函数——current
current函数,返回当前节点,返回仅含当前节点的节点集合
语法:current()
参数:无
返回值:节点集
示例:
xml:
-
<?xml version="1.0" encoding="UTF-8"?> <colors> <color>red</color> <color>green</color> <color>bluecolor</color> </colors>
xslt:
-
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/colors"> <xsl:for-each select="color"> <xsl:value-of select="current()"/> <br/>
-
</xsl:for-each> </xsl:template> </xsl:stylesheet>
结果:
red
green
blue