|
|
@@ -66,6 +66,58 @@
|
|
|
</xsl:function>
|
|
|
|
|
|
|
|
|
+ <xsl:template name="bp:next_bit_max">
|
|
|
+ <xsl:param name="variant" required="yes"/>
|
|
|
+ <xsl:param name="bit_limit" required="yes"/> <!-- like 6 -->
|
|
|
+ <xsl:param name="max_possible_bit" required="yes"/><!-- like 1111111 -->
|
|
|
+ <xsl:param name="loop" required="no"/>
|
|
|
+ <!--<xsl:message>#80 f. v:<xsl:value-of select="$variant"/>;$bit_limit=<xsl:value-of select="$bit_limit"/>;$max_possible_bit=<xsl:value-of select="$max_possible_bit"/>; $loop=<xsl:value-of select="$loop"/>;</xsl:message>-->
|
|
|
+ <xsl:variable name="variant" select="number($variant) + 1"/><!-- dodajemy 1 aby sprawdzic jak wyglada -->
|
|
|
+ <xsl:variable name="curr_bit" select="bp:decimalToBit($variant)"/>
|
|
|
+ <xsl:variable name="digits">
|
|
|
+ <xsl:for-each select="1 to string-length($curr_bit)">
|
|
|
+ <xsl:if test="substring($curr_bit,.,1) = '1'">
|
|
|
+ <xsl:value-of select="number(1)"/>
|
|
|
+ </xsl:if>
|
|
|
+ </xsl:for-each>
|
|
|
+ </xsl:variable>
|
|
|
+ <xsl:variable name="cur_bit_len" select=" string-length($digits)"/>
|
|
|
+ <xsl:choose>
|
|
|
+ <xsl:when test=" string-length($max_possible_bit)> string-length($curr_bit)">
|
|
|
+ <xsl:value-of select=" $variant - 1 "/>
|
|
|
+ </xsl:when>
|
|
|
+
|
|
|
+ <xsl:when test="number($loop) > 5000012">
|
|
|
+ <!--<xsl:message>#91 loop:<xsl:value-of select="$loop"/>; hit returning $variant=<xsl:value-of select="$variant"/>; $curr_bit=<xsl:value-of select="$curr_bit"/>;</xsl:message>-->
|
|
|
+ <xsl:value-of select="$variant"/>
|
|
|
+ </xsl:when>
|
|
|
+ <xsl:when test="$curr_bit = $max_possible_bit">
|
|
|
+ <!--<xsl:message>#90 brak kolejnych wariantow $variant=<xsl:value-of select="$variant"/>;$bit_limit=<xsl:value-of select="$bit_limit"/>; $curr_bit=<xsl:value-of select="$curr_bit"/></xsl:message>-->
|
|
|
+ <xsl:value-of select="$variant"/>
|
|
|
+ </xsl:when>
|
|
|
+ <xsl:when test="number($cur_bit_len) <= number($bit_limit)">
|
|
|
+ <!--<xsl:variable name="next_bit" select="bp:decimalToBit($variant+1)"/>-->
|
|
|
+ <!--<xsl:message>#104 next <xsl:value-of select="$variant"/></xsl:message>-->
|
|
|
+ <xsl:value-of select="$variant"/>
|
|
|
+ </xsl:when>
|
|
|
+
|
|
|
+ <xsl:when test="number($cur_bit_len) > number($bit_limit)">
|
|
|
+ <!--<xsl:variable name="next_bit" select="bp:decimalToBit($variant+1)"/>-->
|
|
|
+ <!--<xsl:message>#104 next <xsl:value-of select="$variant"/></xsl:message>-->
|
|
|
+ <xsl:call-template name="bp:next_bit_max">
|
|
|
+ <xsl:with-param name="variant" select="$variant"/>
|
|
|
+ <xsl:with-param name="bit_limit" select="$bit_limit"/> <!-- like 6 -->
|
|
|
+ <xsl:with-param name="max_possible_bit" select="$max_possible_bit"/><!-- like 1111111 -->
|
|
|
+ <xsl:with-param name="loop" select="$loop"/>
|
|
|
+ </xsl:call-template>
|
|
|
+ </xsl:when>
|
|
|
+ <!--<xsl:otherwise>
|
|
|
+ <xsl:message terminate="yes">#107 f. else $variant=<xsl:value-of select="$variant"/>; $curr_bit=<xsl:value-of select="$curr_bit"/>; $digits=<xsl:value-of select="$digits"/>;</xsl:message>
|
|
|
+ <xsl:value-of select="$variant"/></xsl:otherwise>-->
|
|
|
+ </xsl:choose>
|
|
|
+ </xsl:template>
|
|
|
+
|
|
|
+
|
|
|
<xsl:function name="bp:next_bit_max">
|
|
|
<!-- for ($i = 1; $i < 1024; $i++) {
|
|
|
$bin = decbin($i);
|