| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- <?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:p5dkp="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/dita_kosztorys_projektowy/p5dkp.xsd"
- exclude-result-prefixes="xs"
- version="2.0">
-
-
- <xsl:function name="p5dkp:true.path">
- <xsl:param name="p5dkp:href"/> <!-- to calculate real path from like file:/Users/a.binder/procesy5-dita-templates-druki/MATRYCA_PROJEKTU_BUDZET_ETAP_ROLA_PRACOWNIK/zalozenia_projektowe///../role//../szablony/rola.dita -->
- <xsl:variable name="path" select="p5dkp:true.path.variable($p5dkp:href)"/>
- <xsl:variable name="test">
- <test>
- <xsl:for-each select="p5dkp:true.path.variable($p5dkp:href)//slash">
- <slash>
- <xsl:copy-of select="@*"/>
-
- <xsl:variable name="next.min.parent.pos" select="min($path//slash[@parent and number(@pos) > current()/@pos ]/@pos)"/>
- <xsl:variable name="next.min.path.pos" select="min($path//slash[ text() and number(@pos) > current()/@pos ]/@pos)"/>
- <xsl:variable name="next.min.parent.pos.count" select="count($path//slash[@parent and number(@pos) > current()/@pos ]/@pos)"/>
- <xsl:variable name="next.min.parent.pos.count.path" select="count($path//slash[@parent and number(@pos) > current()/@pos and number(@pos) < $next.min.path.pos]/@pos)"/>
- <xsl:attribute name="next.min.parent.pos" select="$next.min.parent.pos"/>
- <xsl:attribute name="next.min.path.pos" select="$next.min.path.pos"/>
- <xsl:attribute name="next.min.parent.pos.count" select="$next.min.parent.pos.count"/>
- <xsl:attribute name="next.min.parent.pos.count.path" select="$next.min.parent.pos.count.path"/>
- <xsl:if test="text()"><xsl:attribute name="text" select="text()"/></xsl:if>
- <!--<xsl:text>[</xsl:text><xsl:value-of select="position()"/><xsl:text>]next.min.parent.pos=</xsl:text><xsl:value-of select="$next.min.parent.pos"/><xsl:text> ,next.min.path.pos</xsl:text><xsl:value-of select="$next.min.path.pos"/><xsl:text> ,next.min.parent.pos.count</xsl:text><xsl:value-of select="$next.min.parent.pos.count"/><xsl:text>, next.min.parent.pos.count.path=</xsl:text><xsl:value-of select="$next.min.parent.pos.count.path"/><xsl:if test="@parent"><xsl:text> @parent </xsl:text></xsl:if><xsl:if test="@ignore"><xsl:text> @ignore </xsl:text></xsl:if><xsl:text> [ </xsl:text><xsl:value-of select="text()"/><xsl:text> ]</xsl:text>-->
- <xsl:choose>
- <xsl:when test="@ignore"/>
- <xsl:when test="@parent"/>
- <!--<xsl:when test="$next.min.parent.pos.count.path > 1"><!-\-<xsl:text>../</xsl:text>-\-></xsl:when>-->
- <!--<xsl:when test="$next.min.parent.pos < $next.min.path.pos"/>--> <!-- ignored@pos=<xsl:value-of select="@pos"/>;<xsl:value-of select="."/><xsl:text>/</xsl:text>$next.min.parent.pos=<xsl:value-of select="$next.min.parent.pos"/>;next.min.path.pos=<xsl:value-of select="$next.min.path.pos"/> -->
- <xsl:otherwise>
- <xsl:text>/</xsl:text><xsl:value-of select="text()"/>
- </xsl:otherwise>
- </xsl:choose>
- </slash>
- </xsl:for-each>
- </test>
- </xsl:variable>
- <xsl:variable name="next.min.path.pos" select="min($test//slash[ text()]/number(@pos))"/><!-- najmniejsze dane -->
-
- <xsl:variable name="min.next.min.parent.pos" select="min($test//slash[ @parent ]/number(@pos))"/> <!-- najmniejsze parent -->
- <xsl:variable name="min.next.min.parent.pos.count.path" select="min($test//slash[number(@next.min.parent.pos.count.path) > 0 and not(@ignore) ]/number(@pos))"/> <!-- najmniejszy element gdzie potem jest parent --> <!-- and number(@pos) > $next.min.path.pos -->
- <xsl:variable name="min.next.min.parent.pos.count.path.pos" select="max($test//slash[ number(@pos) < $min.next.min.parent.pos.count.path and text() ]/number(@pos))"/><!-- j.w. ale z danymi -->
- <xsl:variable name="return">
- <xsl:for-each select="p5dkp:true.path.variable($p5dkp:href)//slash[number(@pos) < $min.next.min.parent.pos and number(@pos) >= $next.min.path.pos and number(@pos) < $min.next.min.parent.pos.count.path and number(@pos) <= $min.next.min.parent.pos.count.path.pos ]">
- <xsl:choose>
- <xsl:when test="@ignore"/>
- <xsl:when test="@parent"/>
- <xsl:otherwise>
- <xsl:text>/</xsl:text><xsl:value-of select="text()"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:variable>
- <xsl:variable name="rest" >
- <xsl:for-each select="p5dkp:true.path.variable($p5dkp:href)//slash[number(@pos) > $min.next.min.parent.pos and number(@pos) > $min.next.min.parent.pos.count.path ]">
- <!--<xsl:if test="position() = 1">
- <xsl:text>/..</xsl:text>
- </xsl:if>-->
- <xsl:choose>
- <xsl:when test="@ignore"/>
- <xsl:when test="@parent"><xsl:text>/..</xsl:text></xsl:when>
- <xsl:otherwise>
- <xsl:text>/</xsl:text><xsl:value-of select="text()"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:variable>
- <!--<xsl:message>#133 $path = <xsl:copy-of select="$path" copy-namespaces="no"/></xsl:message>-->
-
- <xsl:choose>
- <xsl:when test="$min.next.min.parent.pos < 1 or not($min.next.min.parent.pos)">
- <xsl:value-of select="replace($p5dkp:href,'//','/')"/>
- </xsl:when>
- <xsl:when test="$rest/text()">
- <xsl:value-of select="p5dkp:true.path(replace(concat($return,$rest),'//','/'))"/>
- </xsl:when>
- </xsl:choose>
- <!--<result>
- <xsl:attribute name="min.next.min.parent.pos.count.path" select="$min.next.min.parent.pos.count.path"/>
- <xsl:attribute name="min.next.min.parent.pos.count.path.pos" select="$min.next.min.parent.pos.count.path.pos"/>
- <xsl:attribute name="min.next.min.parent.pos" select="$min.next.min.parent.pos"/>
- <xsl:attribute name="return" select="$return"/>
-
- <xsl:choose>
- <xsl:when test="$min.next.min.parent.pos < 1 or not($min.next.min.parent.pos)">
- <xsl:attribute name="return_final" select="$p5dkp:href"/>
- </xsl:when>
- <xsl:when test="$rest/text()">
- <xsl:attribute name="rest" select="$rest"/>
- <LOOP_REST>
- <xsl:copy-of select="p5dkp:true.path_TEST_2(concat($return,$rest))" copy-namespaces="no"/>
- </LOOP_REST>
- </xsl:when>
- </xsl:choose>
- <xsl:copy-of select="p5dkp:true.path.variable($p5dkp:href)"/>
- <xsl:copy-of select="$test"/>
- <return><xsl:value-of select="$return"/></return>
- </result>-->
-
- </xsl:function>
-
- <xsl:function name="p5dkp:true.path_TEST_2">
- <xsl:param name="p5dkp:href"/> <!-- to calculate real path from like file:/Users/a.binder/procesy5-dita-templates-druki/MATRYCA_PROJEKTU_BUDZET_ETAP_ROLA_PRACOWNIK/zalozenia_projektowe///../role//../szablony/rola.dita -->
- <xsl:param name="loop" />
- <xsl:variable name="path" select="p5dkp:true.path.variable($p5dkp:href)"/>
- <xsl:variable name="test">
- <test>
- <xsl:for-each select="p5dkp:true.path.variable($p5dkp:href)//slash">
- <slash>
- <xsl:copy-of select="@*"/>
-
- <xsl:variable name="next.min.parent.pos" select="min($path//slash[@parent and number(@pos) > current()/@pos ]/@pos)"/>
- <xsl:variable name="next.min.path.pos" select="min($path//slash[ text() and number(@pos) > current()/@pos ]/@pos)"/>
- <xsl:variable name="next.min.parent.pos.count" select="count($path//slash[@parent and number(@pos) > current()/@pos ]/@pos)"/>
- <xsl:variable name="next.min.parent.pos.count.path" select="count($path//slash[@parent and number(@pos) > current()/@pos and number(@pos) < $next.min.path.pos]/@pos)"/>
-
- <xsl:attribute name="next.min.parent.pos" select="$next.min.parent.pos"/>
- <xsl:attribute name="next.min.path.pos" select="$next.min.path.pos"/>
- <xsl:attribute name="next.min.parent.pos.count" select="$next.min.parent.pos.count"/>
- <xsl:attribute name="next.min.parent.pos.count.path" select="$next.min.parent.pos.count.path"/>
- <xsl:if test="text()"><xsl:attribute name="text" select="text()"/></xsl:if>
- <!--<xsl:text>[</xsl:text><xsl:value-of select="position()"/><xsl:text>]next.min.parent.pos=</xsl:text><xsl:value-of select="$next.min.parent.pos"/><xsl:text> ,next.min.path.pos</xsl:text><xsl:value-of select="$next.min.path.pos"/><xsl:text> ,next.min.parent.pos.count</xsl:text><xsl:value-of select="$next.min.parent.pos.count"/><xsl:text>, next.min.parent.pos.count.path=</xsl:text><xsl:value-of select="$next.min.parent.pos.count.path"/><xsl:if test="@parent"><xsl:text> @parent </xsl:text></xsl:if><xsl:if test="@ignore"><xsl:text> @ignore </xsl:text></xsl:if><xsl:text> [ </xsl:text><xsl:value-of select="text()"/><xsl:text> ]</xsl:text>-->
- <xsl:choose>
- <xsl:when test="@ignore"/>
- <xsl:when test="@parent"/>
- <!--<xsl:when test="$next.min.parent.pos.count.path > 1"><!-\-<xsl:text>../</xsl:text>-\-></xsl:when>-->
- <!--<xsl:when test="$next.min.parent.pos < $next.min.path.pos"/>--> <!-- ignored@pos=<xsl:value-of select="@pos"/>;<xsl:value-of select="."/><xsl:text>/</xsl:text>$next.min.parent.pos=<xsl:value-of select="$next.min.parent.pos"/>;next.min.path.pos=<xsl:value-of select="$next.min.path.pos"/> -->
- <xsl:otherwise>
- <xsl:text>/</xsl:text><xsl:value-of select="text()"/>
- </xsl:otherwise>
- </xsl:choose>
- </slash>
- </xsl:for-each>
- </test>
- </xsl:variable>
- <xsl:variable name="next.min.path.pos" select="min($test//slash[ text()]/number(@pos))"/><!-- najmniejsze dane -->
- <xsl:variable name="min.next.min.parent.pos" select="min($test//slash[ @parent ]/number(@pos))"/> <!-- najmniejsze parent -->
- <xsl:variable name="min.next.min.parent.pos.count.path" select="min($test//slash[number(@next.min.parent.pos.count.path) > 0 and not(@ignore) ]/number(@pos))"/> <!-- najmniejszy element gdzie potem jest parent --> <!-- and number(@pos) > $next.min.path.pos -->
- <xsl:variable name="min.next.min.parent.pos.count.path.pos" select="max($test//slash[ number(@pos) < $min.next.min.parent.pos.count.path and text() ]/number(@pos))"/>
-
- <xsl:variable name="return">
- <xsl:for-each select="p5dkp:true.path.variable($p5dkp:href)//slash[number(@pos) < $min.next.min.parent.pos and number(@pos) >= $next.min.path.pos and number(@pos) < $min.next.min.parent.pos.count.path and number(@pos) <= $min.next.min.parent.pos.count.path.pos ]">
- <xsl:choose>
- <xsl:when test="@ignore"/>
- <xsl:when test="@parent"/>
- <xsl:otherwise>
- <xsl:text>/</xsl:text><xsl:value-of select="text()"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:variable>
- <xsl:variable name="rest" >
- <xsl:for-each select="p5dkp:true.path.variable($p5dkp:href)//slash[number(@pos) > $min.next.min.parent.pos and number(@pos) > $min.next.min.parent.pos.count.path ]">
- <!--<xsl:if test="position() = 1">
- <xsl:text>/..</xsl:text>
- </xsl:if>-->
- <xsl:choose>
- <xsl:when test="@ignore"/>
- <xsl:when test="@parent"><xsl:text>/..</xsl:text></xsl:when>
- <xsl:otherwise>
- <xsl:text>/</xsl:text><xsl:value-of select="text()"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:variable>
-
- <!--<xsl:message>#133 $path = <xsl:copy-of select="$path" copy-namespaces="no"/></xsl:message>-->
- <result_2>
- <xsl:attribute name="loop" select="$loop"/>
- <xsl:attribute name="min.next.min.parent.pos.count.path" select="$min.next.min.parent.pos.count.path"/>
- <xsl:attribute name="min.next.min.parent.pos.count.path.pos" select="$min.next.min.parent.pos.count.path.pos"/>
- <xsl:attribute name="min.next.min.parent.pos" select="$min.next.min.parent.pos"/>
- <xsl:attribute name="return" select="$return"/>
- <xsl:choose>
- <xsl:when test="$min.next.min.parent.pos < 1 or not($min.next.min.parent.pos)">
- <xsl:attribute name="return_final" select="$p5dkp:href"/>
- </xsl:when>
- <xsl:when test="$rest/text()">
- <xsl:attribute name="rest" select="$rest"/>
- <LOOP_REST_2>
- <xsl:attribute name="loop" select="$loop"/>
- <xsl:choose>
- <xsl:when test="$loop < 6">
- <xsl:copy-of select="p5dkp:true.path_TEST_2(concat($return,$rest),$loop + 1)" copy-namespaces="no"/>
- </xsl:when>
- </xsl:choose>
- </LOOP_REST_2>
- </xsl:when>
- </xsl:choose>
- <xsl:copy-of select="p5dkp:true.path.variable($p5dkp:href)"/>
- <xsl:copy-of select="$test"/>
- <return>
- <xsl:attribute name="loop" select="$loop"/>
- <xsl:value-of select="$return"/>
- </return>
- </result_2>
-
-
- </xsl:function>
-
-
-
-
- <xsl:function name="p5dkp:true.path.variable">
- <xsl:param name="p5dkp:href"/>
- <path>
- <xsl:for-each select="tokenize($p5dkp:href,'/')">
- <slash>
- <xsl:attribute name="pos" select="position()"/>
- <xsl:choose>
- <xsl:when test="current() = '..'">
- <xsl:attribute name="parent" select="true()"/>
- </xsl:when>
- <xsl:when test="string-length(.) > 0 ">
- <xsl:value-of select="."/>
- </xsl:when>
- <xsl:when test="string-length(.) > 0 ">
- <xsl:value-of select="."/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="ignore" select="true()"/>
- </xsl:otherwise>
- </xsl:choose>
- </slash>
- </xsl:for-each>
- </path>
- </xsl:function>
-
- <!--<xsl:function name="p5dkp:true.path">
- <xsl:param name="p5dkp:href"/> <!-\- to calculate real path from like file:/Users/a.binder/procesy5-dita-templates-druki/MATRYCA_PROJEKTU_BUDZET_ETAP_ROLA_PRACOWNIK/zalozenia_projektowe///../role//../szablony/rola.dita -\->
- <xsl:variable name="path">
- <path>
- <xsl:for-each select="tokenize($p5dkp:href,'/')">
- <slash>
- <xsl:attribute name="pos" select="position()"/>
- <xsl:choose>
- <xsl:when test="current() = '..'">
- <xsl:attribute name="parent" select="true()"/>
- </xsl:when>
- <xsl:when test="string-length(.) > 0 ">
- <xsl:value-of select="."/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="ignore" select="true()"/>
- </xsl:otherwise>
- </xsl:choose>
- </slash>
- </xsl:for-each>
- </path>
- </xsl:variable>
-
- <!-\-<xsl:copy-of select="$path"/>-\->
- <xsl:variable name="return">
- <xsl:for-each select="$path//slash">
- <xsl:variable name="next.min.parent.pos" select="min($path//slash[@parent and number(@pos) > current()/@pos ]/@pos)"/>
- <xsl:variable name="next.min.path.pos" select="min($path//slash[ text() and number(@pos) > current()/@pos ]/@pos)"/>
- <xsl:variable name="next.min.parent.pos.count" select="count($path//slash[@parent and number(@pos) > current()/@pos ]/@pos)"/>
- <xsl:variable name="next.min.parent.pos.count.path" select="count($path//slash[@parent and number(@pos) > current()/@pos and number(@pos) < $next.min.path.pos]/@pos)"/>
- <xsl:choose>
- <xsl:when test="@ignore"/>
- <xsl:when test="@parent"/>
- <!-\-<xsl:when test="$next.min.parent.pos.count.path > 1"><xsl:text>/..</xsl:text></xsl:when>-\->
- <xsl:when test="$next.min.parent.pos < $next.min.path.pos"/> <!-\- ignored@pos=<xsl:value-of select="@pos"/>;<xsl:value-of select="."/><xsl:text>/</xsl:text>$next.min.parent.pos=<xsl:value-of select="$next.min.parent.pos"/>;next.min.path.pos=<xsl:value-of select="$next.min.path.pos"/> -\->
- <xsl:otherwise>
- <xsl:text>/</xsl:text><xsl:value-of select="text()"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:variable>
- <!-\-<xsl:message>#133 $path = <xsl:copy-of select="$path" copy-namespaces="no"/></xsl:message>-\->
- <xsl:value-of select="$return"/>
- </xsl:function>-->
-
- </xsl:stylesheet>
|