| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- <?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:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
- exclude-result-prefixes="xs system_cache__appinfo"
- version="2.0">
-
- <xsl:output indent="yes"/>
-
-
- <xsl:function name="system_cache__appinfo:escaped_html_to_xml">
- <xsl:param name="html" />
- <xsl:call-template name="system_cache__appinfo:escaped_html_to_xml">
- <xsl:with-param name="html" select="$html"/>
- </xsl:call-template>
- </xsl:function>
-
-
- <xsl:function name="system_cache__appinfo:enter_surround_to">
- <xsl:param name="text" />
- <xsl:param name="surround_with" />
- <xsl:choose>
- <xsl:when test=" contains( $text,' ')">
- <xsl:for-each select="tokenize($text ,' ')">
- <xsl:element name="{$surround_with}"><!-- to jest przetwarzane jak jest tekst lamany -->
- <xsl:value-of select="."/>
- </xsl:element>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="$text"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:function>
-
-
- <xsl:template name="escaped_html_to_xml_and_surrounded_enter">
- <xsl:param name="html" required="yes"/>
- <xsl:param name="enter_surround_to" select="'br'"/>
- <xsl:variable name="element_html" select="$html/name()"/>
- <xsl:variable name="enter_surround_to_get" select="system_cache__appinfo:enter_surround_to($html,$enter_surround_to)"/>
- <xsl:variable name="out">
- <xsl:for-each select="$enter_surround_to_get">
- <xsl:element name="{name()}">
- <xsl:copy-of select="system_cache__appinfo:escaped_html_to_xml(.)"/>
- </xsl:element>
- </xsl:for-each>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test=" count($enter_surround_to_get) >1 ">
- <xsl:copy-of select="$out/*" copy-namespaces="no"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="system_cache__appinfo:escaped_html_to_xml($html)"></xsl:copy-of>
- </xsl:otherwise>
- </xsl:choose>
-
- </xsl:template>
-
-
- <xsl:template name="system_cache__appinfo:escaped_html_to_xml">
- <xsl:param name="html"/>
- <xsl:param name="debug" select="false()"/>
- <xsl:param name="loopno" select="1"/>
- <xsl:variable name="anal_out">
- <anal_out>
- <xsl:for-each select=" tokenize($html,'<') ">
- <xsl:variable name="lt_pos" select="position()"/>
- <lt>
- <xsl:attribute name="lt_pos" select="position()"/>
-
- <!--<xsl:value-of select="."/>-->
- <xsl:for-each select="tokenize(.,'>')">
- <gt>
- <xsl:attribute name="gtnum" select="position()"/>
- <!--<xsl:attribute name="lt_pos" select="$lt_pos"/>-->
- <xsl:choose>
- <xsl:when test="$lt_pos=1 and position()=1">
- <xsl:attribute name="tag_place" select="'before_tag'"/>
- </xsl:when>
- <xsl:when test="$lt_pos=2 and position()=1">
- <xsl:attribute name="tag_place" select="'first_tag'"/>
- </xsl:when>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="position()=1 and $lt_pos>1">
- <xsl:attribute name="is_tag" select="true()"/>
- </xsl:when>
- <xsl:otherwise><xsl:attribute name="is_string" select="true()"/></xsl:otherwise>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test=" contains(.,'/') and position()=1 and $lt_pos>1"><xsl:attribute name="closing" select="true()"/></xsl:when>
- <xsl:when test=" not(contains(.,'/')) and position()=1 and $lt_pos>1"><xsl:attribute name="closing" select="false()"/></xsl:when>
- <!--<xsl:otherwise><xsl:attribute name="closing" select="false()"/></xsl:otherwise>-->
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="position()=1 and $lt_pos>1 and not(contains(.,'/')) and contains(.,' ')">
- <xsl:variable name="attributes">
- <xsl:for-each select="tokenize(.,' ')">
- <el><xsl:value-of select="."/></el>
- </xsl:for-each>
- </xsl:variable>
- <xsl:attribute name="attributes" select="$attributes/el[position()>1]"/>
- <xsl:copy-of select="$attributes/el[position()=1]/text()"/>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
- </xsl:choose>
- <!--<xsl:value-of select="."/>-->
- </gt>
- </xsl:for-each>
- </lt>
- </xsl:for-each>
- </anal_out>
- </xsl:variable>
- <!--<analyse>
- <before_tag><xsl:value-of select="$anal_out/anal_out/lt[@ltnum=1]/gt[@gtnum=1]/text()"/></before_tag>
- <first_tag><xsl:value-of select="$anal_out/anal_out/lt[@ltnum=2]/gt[@gtnum=1]/text()"/></first_tag>
- <closing_tag></closing_tag>
- <after_closing_tag></after_closing_tag>
- </analyse>-->
- <!--<xsl:copy-of select="$anal_out"/>-->
- <xsl:variable name="anal_num">
- <anal_num>
- <xsl:for-each select="$anal_out/anal_out/lt/gt">
- <gt><xsl:attribute name="pos" select="position()"/>
- <xsl:copy-of select="@attributes"/>
- <xsl:choose>
- <xsl:when test="@is_string=true()">
- <xsl:attribute name="level" select="0"/>
- <xsl:value-of select="text()"/></xsl:when>
- <xsl:when test="@is_tag=true() and @closing=false()">
- <xsl:attribute name="level" select="1"/>
- <xsl:choose>
- <xsl:when test=" position()=1">
- <xsl:attribute name="new_gr" select="2"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="new_gr" select="1"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:attribute name="element" select="text()"/>
- </xsl:when>
- <xsl:when test="@is_tag=true() and @closing=true()">
- <xsl:attribute name="level" select="-1"/>
- <xsl:attribute name="element" select="text()"/>
- </xsl:when>
- </xsl:choose>
- </gt>
- </xsl:for-each>
- </anal_num>
- </xsl:variable>
- <!--<xsl:copy-of select="$anal_num"/>-->
- <xsl:variable name="anal_num1">
- <anal_num1>
- <xsl:for-each select="$anal_num/anal_num/gt">
- <gt>
- <xsl:copy-of select="@*"/>
- <xsl:choose>
- <xsl:when test="@level=0 and $anal_num/anal_num/gt[number(@pos)= number(current()/@pos)-1]/@level=1"><xsl:attribute name="level" select="1"/></xsl:when><!-- and $anal_num/anal_num/gt[@pos=current()/@pos-1]/@level= -->
- <xsl:when test="@level=0 and $anal_num/anal_num/gt[number(@pos)= number(current()/@pos)-1]/@level=-1"><xsl:attribute name="level" select="-1"/></xsl:when>
- <xsl:otherwise><xsl:attribute name="level" select="@level"/></xsl:otherwise>
- </xsl:choose>
- <xsl:value-of select="text()"/>
- </gt>
- </xsl:for-each>
- </anal_num1>
- </xsl:variable>
- <!--<xsl:copy-of select="$anal_num1"/>-->
- <xsl:variable name="anal_num_anal">
- <anal_num_anal>
- <xsl:for-each select="$anal_num1/anal_num1/gt">
- <gt>
- <xsl:variable name="cur_pos" select="@pos"/>
- <!--<xsl:attribute name="what_sum" select="concat('sum($anal_num/anal_num/gt[@pos<=',$cur_pos,']/@level')" />-->
- <xsl:choose>
- <xsl:when test="sum($anal_num1/anal_num1/gt[number(@pos)<= number($cur_pos) ]/@level)<0">
- <xsl:attribute name="sum_cur" select="1"/>
- <xsl:attribute name="sum_cur_293" select="true()"/>
- </xsl:when>
- <!--<xsl:when test="@level=-1">
- <xsl:attribute name="sum_cur" select="sum($anal_num1/anal_num1/gt[number(@pos)<number($cur_pos) ]/@level)+1"/>
- </xsl:when>-->
- <xsl:otherwise><xsl:attribute name="sum_cur" select="sum($anal_num1/anal_num1/gt[number(@pos)<= number($cur_pos) ]/@level)+1"/></xsl:otherwise>
- </xsl:choose>
-
- <xsl:copy-of select="@*"/>
- <xsl:value-of select="text()"/>
- <!--<copy>
- <xsl:copy-of select="$anal_num/anal_num/gt[ number(@pos)<= number($cur_pos) ]"/>
- </copy>-->
- </gt>
- </xsl:for-each>
- </anal_num_anal>
- </xsl:variable>
- <!--<xsl:copy-of select="$anal_num_anal"/>-->
- <xsl:for-each select="$anal_num_anal/anal_num_anal/gt[@sum_cur=1]"><!-- text outside of first tag -->
- <xsl:variable name="min_pos_sum_cur_1" select="min($anal_num_anal/anal_num_anal/gt[@sum_cur=1 and number(@pos)>number(current()/@pos)]/@pos)"/>
- <xsl:value-of select="text()"/>
- <xsl:for-each select="$anal_num_anal/anal_num_anal/gt[@sum_cur=2 and number(@pos)>number(current()/@pos) and number(@pos)<number($min_pos_sum_cur_1) and @level=1 ]"><!-- first level tags -->
- <xsl:element name="{@element}">
- <xsl:choose>
- <xsl:when test="@attributes">
- <xsl:variable name="attributes">
- <xsl:for-each select="tokenize(@attributes,' ')">
- <e300><xsl:attribute name="val" select="."/>
- <xsl:for-each select="tokenize(.,'="')">
- <e302><xsl:attribute name="val" select="."/>
- <!--<xsl:attribute name="{.}" select="true()"/>-->
- <xsl:for-each select="tokenize(.,'"')">
- <e307>
- <xsl:attribute name="val" select="."/>
- </e307>
- </xsl:for-each>
- </e302>
- </xsl:for-each>
- </e300>
- </xsl:for-each>
- </xsl:variable>
- <xsl:for-each select="$attributes/e300">
- <xsl:attribute name="{e302[1]/@val}" select="e302[2]/e307[1]/@val"/>
- </xsl:for-each>
- <!--<xsl:copy-of select="$attributes"/>-->
- </xsl:when>
- </xsl:choose>
- <xsl:variable name="html2">
- <xsl:for-each select="$anal_num_anal/anal_num_anal/gt[@sum_cur>2 and number(@pos)>number(current()/@pos) and number(@pos)<number($min_pos_sum_cur_1) ]"><!-- text of 1 level tags -->
- <xsl:choose>
- <xsl:when test="@element"><<xsl:value-of select="@element"/>></xsl:when>
- <xsl:otherwise><xsl:copy-of select="text()"/></xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:variable>
- <xsl:call-template name="system_cache__appinfo:escaped_html_to_xml">
- <xsl:with-param name="html" select="$html2"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:for-each>
- </xsl:for-each>
- <xsl:choose><!-- warunek xxxx<br>yyyy nie zwraca - daje IFa -->
- <xsl:when test=" count($anal_num1/anal_num1/gt) = 3
- and $anal_num_anal/anal_num_anal/gt[1][ @sum_cur='1' and @pos='1' and @level='0']
- and $anal_num_anal/anal_num_anal/gt[2][ @sum_cur='2' and @pos='2' and @level='1' and @new_gr='1']
- and $anal_num_anal/anal_num_anal/gt[3][ @sum_cur='3' and @pos='3' and @level='1']
- "><xsl:value-of select="' '"/><xsl:value-of select="$anal_num_anal/anal_num_anal/gt[3]/text()"/></xsl:when>
- </xsl:choose>
- </xsl:template>
-
-
-
- </xsl:stylesheet>
|