XSLT函数——current

      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

posted @ 2010-01-17 00:34  Asharp  阅读(444)  评论(0编辑  收藏  举报