|
|
@@ -0,0 +1,180 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
|
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
|
+ xmlns:bp="https://procesy5.pl/biale_plamy-schema.xsd"
|
|
|
+ xmlns:math="http://exslt.org/math"
|
|
|
+ exclude-result-prefixes="xs"
|
|
|
+ version="2.0">
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <xsl:output indent="yes"/>
|
|
|
+ <xsl:strip-space elements="*"/>
|
|
|
+
|
|
|
+
|
|
|
+ <!--<xsl:function name="bp:decimalToHex">
|
|
|
+ <xsl:param name="dec"/>
|
|
|
+ <xsl:if test="$dec > 0">
|
|
|
+ <xsl:value-of
|
|
|
+ select="bp:decimalToHex(floor($dec div 16)),substring('0123456789ABCDEF', (($dec mod 16) + 1), 1)"
|
|
|
+ separator=""
|
|
|
+ />
|
|
|
+ </xsl:if>
|
|
|
+ </xsl:function>-->
|
|
|
+
|
|
|
+ <xsl:function name="bp:decimalToBit">
|
|
|
+ <xsl:param name="dec"/>
|
|
|
+ <xsl:if test="$dec > 0">
|
|
|
+ <xsl:value-of
|
|
|
+ select="bp:decimalToBit(floor($dec div 2)),substring('01', (($dec mod 2) + 1), 1)"
|
|
|
+ separator=""
|
|
|
+ />
|
|
|
+ </xsl:if>
|
|
|
+ </xsl:function>
|
|
|
+
|
|
|
+ <xsl:function name="bp:decimalToBitFill">
|
|
|
+ <xsl:param name="dec" required="yes"/>
|
|
|
+ <xsl:param name="len" required="yes"/>
|
|
|
+ <xsl:variable name="bin" select=" string-join(bp:decimalToBit($dec),'')"/>
|
|
|
+ <xsl:variable name="strlen" select="string-length($bin)"/>
|
|
|
+ <xsl:variable name="brak_str" select="$len - $strlen"/>
|
|
|
+ <!--<xsl:value-of select="concat(444,$strlen)"/>-->
|
|
|
+ <!--<xsl:value-of select=" string($strlen)"/>-->
|
|
|
+ <xsl:variable name="result">
|
|
|
+ <xsl:choose>
|
|
|
+ <xsl:when test="$strlen = $len">
|
|
|
+ <xsl:value-of select="$bin"/>
|
|
|
+ </xsl:when>
|
|
|
+ <xsl:when test="$strlen > $len">
|
|
|
+ <xsl:value-of select="''"/>
|
|
|
+ </xsl:when>
|
|
|
+ <xsl:otherwise>
|
|
|
+ <xsl:for-each select="1 to $brak_str ">
|
|
|
+ <xsl:value-of select="0"/>
|
|
|
+ </xsl:for-each>
|
|
|
+ <xsl:copy-of select="$bin"/>
|
|
|
+ </xsl:otherwise>
|
|
|
+ </xsl:choose>
|
|
|
+ </xsl:variable>
|
|
|
+ <xsl:copy-of select="$result" />
|
|
|
+ </xsl:function>
|
|
|
+
|
|
|
+ <xsl:function name="bp:if_bit_pos">
|
|
|
+ <xsl:param name="bit"/>
|
|
|
+ <xsl:param name="pos"/>
|
|
|
+ <xsl:value-of select=" substring($bit,number($pos),1)"/>
|
|
|
+ </xsl:function>
|
|
|
+
|
|
|
+ <xsl:template name="PE_wariant_bit_table">
|
|
|
+ <xsl:param name="wariant_id" required="yes"/>
|
|
|
+ <xsl:param name="elements_cnt" required="yes"/>
|
|
|
+ <xsl:param name="bit" required="yes"/>
|
|
|
+ <xsl:param name="bit_limit" required="yes"/>
|
|
|
+ <xsl:variable name="table">
|
|
|
+ <variant>
|
|
|
+ <xsl:for-each select="1 to $elements_cnt">
|
|
|
+ <pos>
|
|
|
+ <xsl:attribute name="pos" select="."/>
|
|
|
+ <!--<xsl:attribute name="bin_pos" select=" bp:if_bit_pos($bit,.)"/>-->
|
|
|
+ <xsl:if test=" string-length($bit) > 0">
|
|
|
+ <xsl:attribute name="bin_pos" select="substring($bit,.,1)"/>
|
|
|
+ </xsl:if>
|
|
|
+ <!--<xsl:attribute name="bin_poss" select="$bit"/>-->
|
|
|
+ <!--<xsl:value-of select="substring($bit,.,1)"/>-->
|
|
|
+ </pos>
|
|
|
+ </xsl:for-each>
|
|
|
+ </variant>
|
|
|
+ </xsl:variable>
|
|
|
+
|
|
|
+ <xsl:variable name="sum_bit" select="sum($table/variant/pos/@bin_pos)"/>
|
|
|
+ <!--<xsl:variable name="sum_bit" select="1"/>-->
|
|
|
+ <xsl:choose>
|
|
|
+ <xsl:when test="$sum_bit = $elements_cnt and $sum_bit <= $bit_limit">
|
|
|
+ <variant>
|
|
|
+ <xsl:attribute name="no_more_variants" select="$sum_bit"/>
|
|
|
+ <xsl:attribute name="elements_cnt" select="$elements_cnt"/>
|
|
|
+ <xsl:attribute name="bit_count" select="$sum_bit"/>
|
|
|
+ </variant>
|
|
|
+ </xsl:when>
|
|
|
+ <xsl:when test="$sum_bit = $elements_cnt">
|
|
|
+ <variant>
|
|
|
+ <xsl:attribute name="no_more_variants" select="$sum_bit"/>
|
|
|
+ <xsl:attribute name="elements_cnt" select="$elements_cnt"/>
|
|
|
+ <xsl:copy-of select="$table"/>
|
|
|
+ </variant>
|
|
|
+ </xsl:when>
|
|
|
+ <xsl:when test="$sum_bit <= $bit_limit">
|
|
|
+ <variant>
|
|
|
+ <xsl:attribute name="bit_count" select="$sum_bit"/>
|
|
|
+ <xsl:copy-of select="$table"/>
|
|
|
+ </variant>
|
|
|
+ </xsl:when>
|
|
|
+ <xsl:otherwise>
|
|
|
+ <variant>
|
|
|
+ <xsl:attribute name="bit_limit_hit" select="$sum_bit"/>
|
|
|
+ </variant>
|
|
|
+ </xsl:otherwise>
|
|
|
+ </xsl:choose>
|
|
|
+
|
|
|
+ </xsl:template>
|
|
|
+
|
|
|
+ <xsl:template name="main">
|
|
|
+ <xsl:call-template name="PE_wariant"/>
|
|
|
+ </xsl:template>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <xsl:template name="PE_wariant">
|
|
|
+ <xsl:param name="elements_cnt" select="20"/>
|
|
|
+ <xsl:param name="bit_max" select="63"/>
|
|
|
+ <xsl:param name="EconomicDistanceCut2"/><!-- tabela do podstawiania danych i wyliczen -->
|
|
|
+ <PE_wariant_bit_table>
|
|
|
+ <xsl:variable name="no_more_variants" select=" math:power(2,$elements_cnt)"/>
|
|
|
+ <xsl:attribute name="no_more_variants" select="$no_more_variants"/>
|
|
|
+ <xsl:for-each select="1 to ($no_more_variants+1)">
|
|
|
+ <xsl:variable name="wariant_id" select="."/>
|
|
|
+ <!--<test><xsl:attribute name="wariant_id" select="."/>
|
|
|
+ <xsl:variable name="bit" select=" string-join(bp:decimalToBitFill(.,$elements_cnt),'')"/>
|
|
|
+ <xsl:attribute name="bit" select=" string-length($bit)"/>
|
|
|
+ <xsl:value-of select="$bit"/>
|
|
|
+ </test>-->
|
|
|
+ <xsl:variable name="bit" select=" string-join(bp:decimalToBitFill(.,$elements_cnt),'')"/>
|
|
|
+ <xsl:variable name="bit2" select=" string-join(bp:decimalToBit($wariant_id),'')"/>
|
|
|
+
|
|
|
+ <xsl:variable name="PE_wariant_bit_table">
|
|
|
+ <PE_wariant_bit_table>
|
|
|
+ <xsl:attribute name="wariant_id" select="."/>
|
|
|
+ <xsl:attribute name="bit" select="$bit" />
|
|
|
+ <xsl:attribute name="bit2" select="$bit2" />
|
|
|
+ <xsl:call-template name="PE_wariant_bit_table">
|
|
|
+ <xsl:with-param name="wariant_id" select="$wariant_id"/>
|
|
|
+ <xsl:with-param name="elements_cnt" select="$elements_cnt"/>
|
|
|
+ <xsl:with-param name="bit" select="bp:decimalToBitFill($wariant_id,$elements_cnt)"/>
|
|
|
+ <xsl:with-param name="bit_limit" select="$bit_max"/>
|
|
|
+ </xsl:call-template>
|
|
|
+ </PE_wariant_bit_table>
|
|
|
+ </xsl:variable>
|
|
|
+ <xsl:choose>
|
|
|
+ <xsl:when test="$PE_wariant_bit_table/PE_wariant_bit_table/variant[@bit_limit_hit]">
|
|
|
+ <PE_wariant_bit_table>
|
|
|
+ <xsl:attribute name="wariant_id" select="$wariant_id"/>
|
|
|
+ <xsl:attribute name="bit_limit_hit" select="$PE_wariant_bit_table/PE_wariant_bit_table/variant/@bit_limit_hit"/>
|
|
|
+ <xsl:copy-of select="$PE_wariant_bit_table/PE_wariant_bit_table"/>
|
|
|
+ </PE_wariant_bit_table>
|
|
|
+ </xsl:when>
|
|
|
+ <xsl:when test="$PE_wariant_bit_table/PE_wariant_bit_table/variant[@no_more_variants]">
|
|
|
+ <PE_wariant_bit_table>
|
|
|
+ <xsl:attribute name="wariant_id" select="$wariant_id"/>
|
|
|
+ <xsl:attribute name="no_more_variants" select="$PE_wariant_bit_table/PE_wariant_bit_table/variant/@no_more_variants"/>
|
|
|
+ <xsl:copy-of select="$PE_wariant_bit_table/PE_wariant_bit_table"/>
|
|
|
+ </PE_wariant_bit_table>
|
|
|
+ </xsl:when>
|
|
|
+ <xsl:otherwise>
|
|
|
+ <xsl:copy-of select="$PE_wariant_bit_table"/>
|
|
|
+ </xsl:otherwise>
|
|
|
+ </xsl:choose>
|
|
|
+ </xsl:for-each>
|
|
|
+ </PE_wariant_bit_table>
|
|
|
+ </xsl:template>
|
|
|
+
|
|
|
+</xsl:stylesheet>
|