XSL中几个封装的函数
来源:互联网 发布:中国知名人工智能专家 编辑:程序博客网 时间:2024/05/16 23:48
布尔操作函数
<!-- ======================================================== -->
<!-- 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>
- XSL中几个封装的函数
- 自己封装的几个函数
- JS封装的几个位操作函数
- JS里面几个实用的封装函数
- //自己封装的几个函数方便记忆
- 几个封装很好的文件函数
- XSL函数二----DOM中对象的方法
- 函数封装时几个封装方法
- Selenium学习笔记之五:封装几个通用的函数
- RichView的几个封装函数(插入文本和图片)
- XSL中循环的实现
- XSL函数
- xsl函数
- fortran中调用C封装的函数
- 关于java中函数功能的封装
- linux中对SQLite3函数的封装
- js中抖函数的封装
- 字符串中封装好的函数
- 在WinForm应用程序中实现自动升级
- 一些常用的物理量计算
- 使用XPathExpression类对XML进行排序
- 分析黑客之门
- javascript实用代码大全
- XSL中几个封装的函数
- 安装程序打包的时候,怎么象petshop一样,把数据库也打到里边
- 在XSL中得到任意节点在DOM树中的深度
- IOMMU概念,优点,缺点
- 将移位操作符用于IO
- Design Patterns学习笔记:Decorator装饰模式
- XP配置IIS+ASP详解(新手本机调试ASP必读)
- ultrachart的使用(一):从数据库中提取数据
- 安装vsftp