中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > .NET > XML/SOAP
XSL中几个封装的函数
作者:未知 时间:2003-06-16 12:12 出处:互联网 责编:chinaitpower
              摘要:暂无

布尔操作函数

<!-- ======================================================== --> <!-- Function: BooleanOR(<value1>,<value2>) => number --> <!-- Parameters:- --> <!-- <value1> - the first number to be ORed --> <!-- <value2> - the second number to be ORed --> <!-- NB. Only works with unsigned ints! --> <xsl:template name="BooleanOR"> <xsl:param name="value1" select="number(0)"/> <xsl:param name="value2" select="number(0)"/> <!-- recurse parameters --> <xsl:param name="bitval" select="number(2147483648)"/> <xsl:param name="accum" select="number(0)"/> <!-- calc bits present on values --> <xsl:variable name="bit1" select="floor($value1 div $bitval)"/> <xsl:variable name="bit2" select="floor($value2 div $bitval)"/> <!-- do the OR on the bits --> <xsl:variable name="thisbit"> <xsl:choose> <xsl:when test="($bit1 != 0) or ($bit2 != 0)"><xsl:value-of select="$bitval"/></xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable> <!-- if last recurse then output the value --> <xsl:choose> <xsl:when test="$bitval = 1"><xsl:value-of select="$accum + $thisbit"/></xsl:when> <xsl:otherwise> <!-- recurse required --> <xsl:call-template name="BooleanOR"> <xsl:with-param name="value1" select="$value1 mod $bitval"/> <xsl:with-param name="value2" select="$value2 mod $bitval"/> <xsl:with-param name="bitval" select="$bitval div 2"/> <xsl:with-param name="accum" select="$accum + $thisbit"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- ======================================================== --> <!-- Function: BooleanAND(<value1>,<value2>) => number --> <!-- Parameters:- --> <!-- <value1> - the first number to be ANDed --> <!-- <value2> - the second number to be ANDed --> <!-- NB. Only works with unsigned ints! --> <xsl:template name="BooleanAND"> <xsl:param name="value1" select="number(0)"/> <xsl:param name="value2" select="number(0)"/> <!-- recurse parameters --> <xsl:param name="bitval" select="number(2147483648)"/> <xsl:param name="accum" select="number(0)"/> <!-- calc bits present on values --> <xsl:variable name="bit1" select="floor($value1 div $bitval)"/> <xsl:variable name="bit2" select="floor($value2 div $bitval)"/> <!-- do the AND on the bits --> <xsl:variable name="thisbit"> <xsl:choose> <xsl:when test="($bit1 != 0) and ($bit2 != 0)"><xsl:value-of select="$bitval"/></xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable> <!-- if last recurse then output the value --> <xsl:choose> <xsl:when test="$bitval = 1"><xsl:value-of select="$accum + $thisbit"/></xsl:when> <xsl:otherwise> <!-- recurse required --> <xsl:call-template name="BooleanAND"> <xsl:with-param name="value1" select="$value1 mod $bitval"/> <xsl:with-param name="value2" select="$value2 mod $bitval"/> <xsl:with-param name="bitval" select="$bitval div 2"/> <xsl:with-param name="accum" select="$accum + $thisbit"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- ======================================================== --> <!-- Function: BooleanXOR(<value1>,<value2>) => number --> <!-- Parameters:- --> <!-- <value1> - the first number to be XORed --> <!-- <value2> - the second number to be XORed --> <!-- NB. Only works with unsigned ints! --> <xsl:template name="BooleanXOR"> <xsl:param name="value1" select="number(0)"/> <xsl:param name="value2" select="number(0)"/> <!-- recurse parameters --> <xsl:param name="bitval" select="number(2147483648)"/> <xsl:param name="accum" select="number(0)"/> <!-- calc bits present on values --> <xsl:variable name="bit1" select="floor($value1 div $bitval)"/> <xsl:variable name="bit2" select="floor($value2 div $bitval)"/> <!-- do the XOR on the bits --> <xsl:variable name="thisbit"> <xsl:choose> <xsl:when test="(($bit1 != 0) and ($bit2 = 0)) or (($bit1 = 0) and ($bit2 != 0))"><xsl:value-of select="$bitval"/></xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable> <!-- if last recurse then output the value --> <xsl:choose> <xsl:when test="$bitval = 1"><xsl:value-of select="$accum + $thisbit"/></xsl:when> <xsl:otherwise> <!-- recurse required --> <xsl:call-template name="BooleanXOR"> <xsl:with-param name="value1" select="$value1 mod $bitval"/> <xsl:with-param name="value2" select="$value2 mod $bitval"/> <xsl:with-param name="bitval" select="$bitval div 2"/> <xsl:with-param name="accum" select="$accum + $thisbit"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template>
关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有