XSLT函数——function-available()

       function-available(string)函数用于测试某个函数是否可以被XSLT处理器解析。参数string用于指定要测试的函数名。

      语法:function-available(string)

      参数:string字符串,必需

      返回:布尔型

示例:

xml:

  1. <?xml version="1.0" encoding="UTF-8"?>
    <books>
       <book id="1">
            <name>XSLT</name>   
       </book>
    </books>

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="gb2312" indent="yes"/>    
        <xsl:template match="/books">
           <xsl:choose>
                <xsl:when test="function-available('current')">
                   <xsl:copy-of select="."/>
                </xsl:when>
                <xsl:otherwise>
                   <xsl:text>current函数不可用</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>
    </xsl:stylesheet>

结果:

  1. XSLT
posted @ 2010-01-17 02:25  Asharp  阅读(355)  评论(0编辑  收藏  举报