现在的位置: 首页 > 综合 > 正文

XSLT函数——current

2013年06月30日 ⁄ 综合 ⁄ 共 1991字 ⁄ 字号 评论关闭

      current函数,返回当前节点,返回仅含当前节点的节点集合

      语法:current()

      参数:无

     返回值:节点集

     示例:

xml:

  1. <?xml version="1.0" encoding="UTF-8"?>
    <colors>
      <color>red</color>
      <color>green</color>
      <color>bluecolor</color>
    </colors>

xslt:

  1. <?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/>
  2.         </xsl:for-each>    
        </xsl:template>
    </xsl:stylesheet>

结果:

red

green

blue

【上篇】
【下篇】

抱歉!评论已关闭.