XSL에 포함된 함수 - 부울 작업 함수
7142 단어 XSL
<!-- ======================================================== -->
<!-- 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>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[C#] 한 걸음 한 걸음 자신의 자동 코드 생성 도구 개발 6: 업무층 템플릿텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.