a.binder 6 år sedan
förälder
incheckning
14bbb2ce70

+ 1 - 1
SE/schema/ant-url_action/default_db.in7_dziennik_koresp/umowa_zleceniobiorca/IN7_DZIENNIK_KORESP.dita

@@ -29,7 +29,7 @@
             <p><ph>nip:</ph><ph xpath="nip"/><ph> regon:</ph><ph xpath="regon"/></p>
             <p><ph>email:</ph><ph xpath="BILLING_OWNER_EMAIL"/> <ph> tel:</ph><ph xpath="tel"/> </p>
             <p><ph>nr r-ku:</ph><ph xpath="nr_rach"/></p>
-            <svg-container xpath="BILLING_OWNER_LOGO_SVG" format="system_cache__appinfo:escaped_html_to_xml"/>
+            <svg-container xpath="BILLING_OWNER_LOGO_SVG" format="system_cache__appinfo:escaped_html_to_xml" />
               
             
         </RelatedFeature></stentry>

+ 294 - 45
SE/schema/default_db_xml_cache.public/escaped_html_to_xml.xsl

@@ -5,7 +5,7 @@
     exclude-result-prefixes="xs system_cache__appinfo"
     version="2.0">
     
-    <xsl:param name="system_cache__appinfo:escaped_html_to_xml.debug" select="5"/>
+    <xsl:param name="system_cache__appinfo:escaped_html_to_xml.debug" />
     
     <xsl:output indent="yes"/>
     
@@ -137,6 +137,7 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
         <xsl:param name="debug" select="false()"/>
         <xsl:param name="loopno" select="1"/>
         <xsl:param name="TO_DELETE_STRING" select="'___TO_DELETE_STRING____'" /> <!-- required="yes" -->
+        <xsl:param name="xpath-default-namespace"/>
         <xsl:variable name="anal_out">
             <anal_out>
                 <xsl:for-each select=" tokenize($html,'&lt;') ">
@@ -144,13 +145,16 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
                         <xsl:message>#131 matched &lt; </xsl:message>
                     </xsl:if>
                     <xsl:variable name="lt_pos" select="position()"/>
+                    <xsl:variable name="lt_pos.last" select="last()"/>
                     <lt>
                         <xsl:attribute name="lt_pos" select="position()"/>
+                        <xsl:attribute name="ltnum" select="position()"/>
                         
                         <!--<xsl:value-of select="."/>-->
                         <xsl:for-each select="tokenize(.,'&gt;')">
                             <gt>
                                 <xsl:attribute name="gtnum" select="position()"/>
+                                <xsl:attribute name="lt_pos" select="$lt_pos"/>
                                 <xsl:choose>
                                     <xsl:when test="contains(.,'/')">
                                         <xsl:attribute name="debug.contains.slash" select="true()"/>
@@ -158,6 +162,8 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
                                     </xsl:when>
                                 </xsl:choose>
                                 <xsl:attribute name="debug.last.char" select="substring(.,string-length(.)) "/>
+                                <xsl:attribute name="debug.lt_pos.last" select="$lt_pos.last"/>
+                                <xsl:attribute name="debug.current" select="current()"/>
                                 <!--<xsl:attribute name="debug.string.current" select="."/>-->
                                 <!--<xsl:attribute name="lt_pos" select="$lt_pos"/>-->
                                 <xsl:choose>
@@ -167,8 +173,14 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
                                     <xsl:when test="$lt_pos=2 and position()=1">
                                         <xsl:attribute name="tag_place" select="'first_tag'"/>
                                     </xsl:when>
+                                    <xsl:when test="$lt_pos=$lt_pos.last and contains(.,$TO_DELETE_STRING)">
+                                        <xsl:attribute name="tag_place" select="'after_closing_tag'"/>
+                                    </xsl:when>
                                 </xsl:choose>
                                 <xsl:choose>
+                                    <xsl:when test="position()=1 and $lt_pos&gt;1 and contains(substring(.,1,1),'/') ">
+                                        <xsl:attribute name="is_tag" select="false()"/>
+                                    </xsl:when>
                                     <xsl:when test="position()=1 and $lt_pos&gt;1">
                                         <xsl:attribute name="is_tag" select="true()"/>
                                     </xsl:when>
@@ -176,6 +188,7 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
                                 </xsl:choose>
                                 <xsl:choose>
                                     <xsl:when test=" contains(substring(.,string-length(.)),'/') and position()=1 and $lt_pos &gt; 1"><xsl:attribute name="closing" select="true()"/></xsl:when>
+                                    <xsl:when test=" contains(substring(.,1,1),'/') and position()=1 and $lt_pos &gt; 1"><xsl:attribute name="closing" select="true()"/></xsl:when>
                                     <xsl:when test=" not(contains(substring(.,string-length(.)),'/')) and position()=1 and $lt_pos &gt; 1"><xsl:attribute name="closing" select="false()"/></xsl:when>
                                     <!--<xsl:otherwise><xsl:attribute name="closing" select="false()"/></xsl:otherwise>-->
                                 </xsl:choose>
@@ -196,9 +209,32 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
                                             + pos1/text = (<xsl:value-of select="$attributes/el[position()=1]/text()"/>)
                                         </xsl:message></xsl:if>
                                         <xsl:attribute name="attributes" select="$attributes/el[position()&gt;1]"/>
-                                        <xsl:copy-of select="$attributes/el[position()=1]/text()"/>
+                                        <!--<xsl:copy-of select="$attributes/el[position()=1]/text()"/>-->
+                                        <xsl:value-of select="."/>
+                                    </xsl:when>
+                                    <xsl:when test="position()=1 and $lt_pos&gt;1 and contains(substring(.,string-length(.)),'/') and contains(.,' ')">
+                                        <xsl:variable name="attributes">
+                                            
+                                            <!--<xsl:for-each select="tokenize(.,'=&quot;')">
+                                                
+                                            </xsl:for-each>-->
+                                            
+                                            <xsl:for-each select="tokenize(.,' ')">
+                                                <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3"><xsl:message>#183.B attr token(<xsl:value-of select="."/>)</xsl:message></xsl:if>
+                                                <el><xsl:value-of select="."/></el>
+                                            </xsl:for-each>
+                                        </xsl:variable>
+                                        <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3"><xsl:message>#187 attributes= (<xsl:value-of select="$attributes/el[position()&gt;1]"/>)
+                                            + pos1/text = (<xsl:value-of select="$attributes/el[position()=1]/text()"/>)
+                                        </xsl:message></xsl:if>
+                                        <xsl:attribute name="attributes" select="$attributes/el[position()&gt;1]"/>
+                                        <!--<xsl:copy-of select="$attributes/el[position()=1]/text()"/>-->
+                                        <xsl:value-of select="."/>
                                     </xsl:when>
-                                    <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
+                                    
+                                    <xsl:otherwise>
+                                        <xsl:attribute name="debug.attributes">Otherwise 214</xsl:attribute>
+                                        <xsl:value-of select="."/></xsl:otherwise>
                                 </xsl:choose>
                                 <!--<xsl:value-of select="."/>-->
                             </gt>
@@ -222,7 +258,24 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
                 <xsl:for-each select="$anal_out/anal_out/lt/gt">
                     <gt><xsl:attribute name="pos" select="position()"/>
                         <xsl:copy-of select="@attributes"/>
+                        <xsl:copy-of select="@is_tag"/>
+                        <xsl:copy-of select="@closing"/>
+                        <xsl:copy-of select="@tag_place"/>
+                        <xsl:copy-of select="@is_string"/>
+                        <xsl:copy-of select="@lt_pos"/>
+                        <xsl:copy-of select="@gtnum"/>
                         <xsl:choose>
+                            <xsl:when test="@closing=true() and @is_tag=true() and $anal_out/anal_out/lt/gt[ @lt_pos = current()/@lt_pos and @gtnum = number(current()/@gtnum)+1 ]">
+                                <xsl:attribute name="level" select="1"/>
+                                <xsl:attribute name="level.debug">#246-A @closing=true()</xsl:attribute>
+                                <xsl:attribute name="element" select="tokenize(text(),' ')[1]"/>
+                                <xsl:value-of select="text()"/>
+                            </xsl:when>
+                            <xsl:when test="$anal_out/anal_out/lt/gt[ @lt_pos = current()/@lt_pos and @gtnum = number(current()/@gtnum)-1 and @closing=true() and @is_tag=true()]">
+                                <xsl:attribute name="level" select="-1"/>
+                                <xsl:attribute name="level.debug">#246-B @closing=true()</xsl:attribute>
+                                
+                            </xsl:when>
                             <xsl:when test="@is_string=true()">
                                 <xsl:attribute name="level" select="0"/>                                
                                 <xsl:value-of select="text()"/></xsl:when>
@@ -237,11 +290,20 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
                                     </xsl:otherwise>
                                 </xsl:choose>
                                 <xsl:attribute name="element" select="tokenize(text(),' ')[1]"/><!-- text() -->
+                                <xsl:value-of select="text()"/>
                             </xsl:when>
                             <xsl:when test="@is_tag=true() and @closing=true()">
-                                <xsl:attribute name="level" select="-1"/>
+                                <xsl:attribute name="level" select="0"/> <!-- -1 -->
+                                <xsl:attribute name="element" select="tokenize(text(),' ')[1]"/>
+                                <xsl:value-of select="text()"/>
+                            </xsl:when>
+                            <xsl:when test="@is_tag=false() and @closing=true()">
+                                <xsl:attribute name="level" select="-1"/> <!-- -1 -->
                                 <xsl:attribute name="element" select="tokenize(text(),' ')[1]"/>
                             </xsl:when>
+                            <xsl:otherwise>
+                                <xsl:message terminate="yes">#248 otherwise incorrect </xsl:message>
+                            </xsl:otherwise>
                         </xsl:choose>
                     </gt>
                 </xsl:for-each>
@@ -254,8 +316,10 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
                     <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:when test="@tag_place='before_tag'"><xsl:attribute name="level" select="1"/></xsl:when>
+                            <xsl:when test="@tag_place='after_closing_tag'"><xsl:attribute name="level" select="-1"/></xsl:when>
+                           <!-- <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()"/>
@@ -270,6 +334,10 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
                 <xsl:for-each select="$anal_num1/anal_num1/gt">
                     <gt>
                         <xsl:variable name="cur_pos" select="@pos"/>
+                        <xsl:copy-of select="@is_tag"/>
+                        <xsl:copy-of select="@closing"/>
+                        <xsl:copy-of select="@tag_place"/>
+                        <xsl:copy-of select="@is_string"/>
                         <!--<xsl:attribute name="what_sum" select="concat('sum($anal_num/anal_num/gt[@pos&lt;=',$cur_pos,']/@level')" />-->
                         <xsl:choose>
                             <xsl:when test="sum($anal_num1/anal_num1/gt[number(@pos)&lt;= number($cur_pos) ]/@level)&lt;0">
@@ -279,7 +347,18 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
                             <!--<xsl:when test="@level=-1">
                                 <xsl:attribute name="sum_cur" select="sum($anal_num1/anal_num1/gt[number(@pos)&lt;number($cur_pos) ]/@level)+1"/>
                             </xsl:when>-->
-                            <xsl:otherwise><xsl:attribute name="sum_cur" select="sum($anal_num1/anal_num1/gt[number(@pos)&lt;= number($cur_pos) ]/@level)+1"/></xsl:otherwise>
+                            <xsl:when test="@level = 1">
+                                <xsl:attribute name="sum_cur" select="sum($anal_num1/anal_num1/gt[number(@pos)&lt;= number($cur_pos) ]/@level)"/>
+                                <xsl:attribute name="sum_cur_326" select="true()"/>
+                            </xsl:when>
+                            <xsl:when test="@level = -1">
+                                <xsl:attribute name="sum_cur" select="sum($anal_num1/anal_num1/gt[number(@pos)&lt; number($cur_pos) ]/@level)"/>
+                                <xsl:attribute name="sum_cur_329" select="true()"/>
+                            </xsl:when>
+                            <xsl:otherwise>
+                                <xsl:attribute name="sum_cur" select="sum($anal_num1/anal_num1/gt[number(@pos)&lt; number($cur_pos) ]/@level)"/><!-- +1 -->
+                                <xsl:attribute name="sum_cur_305.otherwise" select="true()"/>
+                            </xsl:otherwise>
                         </xsl:choose>
                         
                         <xsl:copy-of select="@*"/>
@@ -295,31 +374,59 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
         <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3"><xsl:copy-of select="$anal_num_anal"/></xsl:if>
         <xsl:variable name="sum_cur_select">
             <xsl:choose>
+                <xsl:when test="$anal_num_anal/anal_num_anal/gt[@tag_place='before_tag']"><xsl:value-of select="2"/>
+                    <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3"><xsl:message>#291-A(before_tag) sum_cur_select==2</xsl:message></xsl:if>
+                </xsl:when>
                 <xsl:when test="$anal_num_anal/anal_num_anal/gt[@sum_cur=1]"><xsl:value-of select="1"/>
-                    <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3"><xsl:message>#291-A sum_cur_select==1</xsl:message></xsl:if>
+                    <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3"><xsl:message>#291-B sum_cur_select==1</xsl:message></xsl:if>
                 </xsl:when>
                 <xsl:otherwise>
-                    <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3"><xsl:message>#291-B sum_cur_select==2</xsl:message></xsl:if>
+                    <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3"><xsl:message>#291-C sum_cur_select==2</xsl:message></xsl:if>
                     <xsl:value-of select="2"/></xsl:otherwise>
             </xsl:choose>
         </xsl:variable>
         <xsl:for-each select="$anal_num_anal/anal_num_anal/gt[@sum_cur=$sum_cur_select]"><!-- text outside of first tag -->
-            <xsl:variable name="min_pos_sum_cur_1" select="min($anal_num_anal/anal_num_anal/gt[@sum_cur=$sum_cur_select and number(@pos)&gt;number(current()/@pos)]/@pos)"/>
-            <xsl:value-of select="replace(text(),$TO_DELETE_STRING,'')"/>
-            <xsl:for-each select="$anal_num_anal/anal_num_anal/gt[@sum_cur=$sum_cur_select+1 and number(@pos)&gt;number(current()/@pos) and  number(@pos)&lt;number($min_pos_sum_cur_1) and @level=1 ]"><!-- first level tags -->
-                <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3"><xsl:message>#275 riding foreach for @pos=<xsl:value-of select="@pos"/>; @element=<xsl:value-of select="@element"/></xsl:message></xsl:if>
+            <xsl:variable name="min_pos_sum_cur_1" select="min($anal_num_anal/anal_num_anal/gt[@sum_cur=$sum_cur_select and number(@pos)&gt;number(current()/@pos) and not(@level='0')]/@pos)"/>
+            <!--<xsl:value-of select="replace(text(),$TO_DELETE_STRING,'')"/>-->
+            <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3"><xsl:message>#309 riding foreach anal_num_anal @pos=<xsl:value-of select="@pos"/>; 
+                @element=<xsl:value-of select="@element"/>; @sum_cur=<xsl:value-of select="@sum_cur"/>; @tag_place="<xsl:value-of select="@tag_place"/>"
+                requested  @level=1; 
+                @sum_cur exact $sum_cur_select==<xsl:value-of select="$sum_cur_select"/>;
+                number(@pos) more==(<xsl:value-of select="current()/@pos"/>) less number($min_pos_sum_cur_1==<xsl:value-of select="$min_pos_sum_cur_1"/>) 
+                Will parse :::: (<xsl:for-each select="$anal_num_anal/anal_num_anal/gt[number(@sum_cur)=$sum_cur_select and number(@pos)&gt;=number(current()/@pos) and  number(@pos)&lt;=number($min_pos_sum_cur_1) and number(@level)=1 ]">,<xsl:value-of select="@pos"/></xsl:for-each>)
+            </xsl:message></xsl:if>
+            
+            <xsl:choose>
+                <xsl:when test="number($min_pos_sum_cur_1) &gt;0"></xsl:when>
+                <xsl:otherwise><xsl:message terminate="no">#332 not set $min_pos_sum_cur_1</xsl:message></xsl:otherwise>
+            </xsl:choose>
+            
+            <xsl:for-each select="$anal_num_anal/anal_num_anal/gt[number(@sum_cur)=$sum_cur_select and number(@pos)&gt;=number(current()/@pos) and  number(@pos)&lt;=number($min_pos_sum_cur_1) and number(@level)=1 ]"><!-- first level tags -->
+                <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3">
+                    <xsl:message>#275 riding foreach for @pos=<xsl:value-of select="@pos"/>; @element=<xsl:value-of select="@element"/></xsl:message>
+                     <xsl:comment>#275 riding foreach for @pos=<xsl:value-of select="@pos"/>; @element=<xsl:value-of select="@element"/></xsl:comment></xsl:if>
                 <xsl:choose>
                     <xsl:when test=" string-length(@element) &gt; 0">
                         <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3"><xsl:message>#78  string-length(@element)=<xsl:value-of select="@element"/>; </xsl:message></xsl:if>
-                        <xsl:element name="{@element}">
+                        <xsl:variable name="namespace" >
                             <xsl:choose>
-                                <xsl:when test="@attributes">
-                                    <xsl:variable name="attributes">
-                                        <!--<xsl:for-each select="tokenize(@attributes,' ')">
+                                <xsl:when test="substring-before(substring-after(@attributes,'xmlns=&quot;'), '&quot;')"><xsl:value-of select="substring-before(substring-after(@attributes,'xmlns=&quot;'), '&quot;')"/></xsl:when>
+                                <xsl:when test="$xpath-default-namespace"><xsl:value-of select="$xpath-default-namespace"/></xsl:when>
+                            </xsl:choose>
+                        </xsl:variable>
+                        
+                        <xsl:choose>
+                            <xsl:when test="substring-before(substring-after(@attributes,'xmlns=&quot;'), '&quot;') or $xpath-default-namespace">
+                                <xsl:element name="{@element}"   namespace="{$namespace}"  ><!-- namespace="http://www.w3.org/2000/svg" --><!-- xpath-default-namespace="http://www.w3.org/2000/svg" -->
+                                    
+                                    <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(.,'=&quot;')">
                                                     <e302><xsl:attribute name="val" select="."/>
-                                                        <!-\-<xsl:attribute name="{.}" select="true()"/>-\->
+                                                        <!-\\-<xsl:attribute name="{.}" select="true()"/>-\\->
                                                         <xsl:for-each select="tokenize(.,'&quot;')">
                                                             <e307>
                                                                 <xsl:attribute name="val" select="."/>
@@ -328,42 +435,109 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
                                                     </e302>
                                                 </xsl:for-each>
                                             </e300>
-                                        </xsl:for-each>-->
-                                        <xsl:for-each select="tokenize(@attributes,'&quot; ')">
-                                            <e300><xsl:attribute name="val" select="concat(.,'&quot;')"/>
-                                                <xsl:for-each select="tokenize(.,'=&quot;')">
-                                                    <e302><xsl:attribute name="val" select="."/>
-                                                        <!--<xsl:attribute name="{.}" select="true()"/>-->
-                                                        <xsl:for-each select="tokenize(.,'&quot;')">
-                                                            <e307>
+                                        </xsl:for-each>-\->
+                                        <!-\-<xsl:for-each select="tokenize(@attributes,'=&quot;')">
+                                            <e300 pos="{position()}"><xsl:attribute name="val" select="."/>
+                                                <xsl:for-each select="tokenize(.,'&quot;')">
+                                                    <e302 pos="{position()}"><xsl:attribute name="val" select="."/>
+                                                        <!-\\-<xsl:attribute name="{.}" select="true()"/>-\\->
+                                                        <xsl:for-each select="tokenize(.,'(&#xA;, )')">
+                                                            <e307 pos="{position()}">
                                                                 <xsl:attribute name="val" select="."/>
                                                             </e307>
                                                         </xsl:for-each>
                                                     </e302>
                                                 </xsl:for-each>
                                             </e300>
-                                        </xsl:for-each>
+                                        </xsl:for-each>-\->
+                                        <unescap_attr>
+                                            <xsl:call-template name="unescapeattributes">
+                                                <xsl:with-param name="escapedattributes" select="@attributes"/>
+                                            </xsl:call-template>
+                                        </unescap_attr>
+                                    </xsl:variable>-->
+                                            
+                                            
+                                            
+                                            <!--<xsl:for-each select="$attributes/e300">
+                                        <xsl:choose>
+                                            <xsl:when test="e302[1]/@val = 'xmlns'">
+                                                <xsl:message>#367-A  bypassed place attr(name="<xsl:value-of select="e302[1]/@val"/>"; val="<xsl:value-of select="e302[2]/e307[1]/@val"/>") </xsl:message>
+                                            </xsl:when>
+                                            <xsl:otherwise>
+                                                <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3"><xsl:message>#367-B  will place attr(name="<xsl:value-of select="e302[1]/@val"/>"; val="<xsl:value-of select="e302[2]/e307[1]/@val"/>") </xsl:message></xsl:if>
+                                                <!-\-<xsl:attribute name="{e302[1]/@val}" select="e302[2]/e307[1]/@val"/>-\->
+                                            </xsl:otherwise>
+                                        </xsl:choose>
                                         
+                                    </xsl:for-each>-->
+                                            <!--<xsl:copy-of select="$attributes"/>-->
+                                            <xsl:call-template name="unescapeattributes">
+                                                <xsl:with-param name="escapedattributes" select="@attributes"/>
+                                            </xsl:call-template>
+                                            
+                                        </xsl:when>
+                                    </xsl:choose>
+                                    <xsl:variable name="html2">
+                                        <xsl:for-each select="$anal_num_anal/anal_num_anal/gt[number(@sum_cur)&gt;1 and number(@pos)&gt;number(current()/@pos) and  number(@pos)&lt;number($min_pos_sum_cur_1) ]"><!-- text of 1 level tags -->
+                                            <xsl:choose>
+                                                <xsl:when test=" @is_tag=true() and @closing=true() ">&lt;<xsl:copy-of select="text()"></xsl:copy-of>&gt;</xsl:when>
+                                                <xsl:when test=" @is_tag=true() and @closing=false() ">&lt;<xsl:copy-of select="text()"></xsl:copy-of>&gt;</xsl:when>
+                                                <xsl:when test=" string-length(@element) &gt; 0">&lt;<xsl:value-of select="@element"/>&gt;</xsl:when>
+                                                <xsl:otherwise><xsl:copy-of select="text()"/></xsl:otherwise>
+                                            </xsl:choose>
+                                        </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&gt;2 and number(@pos)&gt;number(current()/@pos) and  number(@pos)&lt;number($min_pos_sum_cur_1) ]"><!-- text of 1 level tags -->
+                                    <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3">
+                                        <html2 debug="1" min_pos_sum_cur_1="{$min_pos_sum_cur_1}" sum_cur_select="{$sum_cur_select}">
+                                            <xsl:copy-of select="$html2"></xsl:copy-of>
+                                        </html2>
+                                    </xsl:if>
+                                    <xsl:call-template name="system_cache__appinfo:escaped_html_to_xml">
+                                        <xsl:with-param name="html" select="concat($TO_DELETE_STRING,$html2,$TO_DELETE_STRING)"/>
+                                        <xsl:with-param name="TO_DELETE_STRING" select="$TO_DELETE_STRING"/>
+                                        <xsl:with-param name="xpath-default-namespace" select="$namespace"/>
+                                    </xsl:call-template>
+                                </xsl:element>
+                                
+                            </xsl:when>
+                            <xsl:otherwise>
+                                <xsl:element name="{@element}"   ><!-- namespace="http://www.w3.org/2000/svg" --><!-- xpath-default-namespace="http://www.w3.org/2000/svg" -->
+                                    
                                     <xsl:choose>
-                                        <xsl:when test=" string-length(@element) &gt; 0">&lt;<xsl:value-of select="@element"/>&gt;</xsl:when>
-                                        <xsl:otherwise><xsl:copy-of select="text()"/></xsl:otherwise>
+                                        <xsl:when test="@attributes">
+                                            
+                                                                                        
+                                            
+                                            <xsl:call-template name="unescapeattributes">
+                                                <xsl:with-param name="escapedattributes" select="@attributes"/>
+                                            </xsl:call-template>
+                                            
+                                        </xsl:when>
                                     </xsl:choose>
-                                </xsl:for-each>
-                            </xsl:variable>
-                            <xsl:call-template name="system_cache__appinfo:escaped_html_to_xml">
-                                <xsl:with-param name="html" select="concat($TO_DELETE_STRING,$html2,$TO_DELETE_STRING)"/>
-                                <xsl:with-param name="TO_DELETE_STRING" select="$TO_DELETE_STRING"/>
-                            </xsl:call-template>
-                        </xsl:element>
+                                    <xsl:variable name="html2">
+                                        <xsl:for-each select="$anal_num_anal/anal_num_anal/gt[number(@sum_cur)&gt;1 and number(@pos)&gt;number(current()/@pos) and  number(@pos)&lt;number($min_pos_sum_cur_1) ]"><!-- text of 1 level tags -->
+                                            <xsl:choose>
+                                                <xsl:when test=" @is_tag=true() and @closing=true() ">&lt;<xsl:copy-of select="text()"></xsl:copy-of>&gt;</xsl:when>
+                                                <xsl:when test=" @is_tag=true() and @closing=false() ">&lt;<xsl:copy-of select="text()"></xsl:copy-of>&gt;</xsl:when>
+                                                <xsl:when test=" string-length(@element) &gt; 0">&lt;<xsl:value-of select="@element"/>&gt;</xsl:when>
+                                                <xsl:otherwise><xsl:copy-of select="text()"/></xsl:otherwise>
+                                            </xsl:choose>
+                                        </xsl:for-each>
+                                    </xsl:variable>
+                                    <xsl:if test=" number($system_cache__appinfo:escaped_html_to_xml.debug) &gt; 3">
+                                        <html2 debug="1" min_pos_sum_cur_1="{$min_pos_sum_cur_1}" sum_cur_select="{$sum_cur_select}">
+                                            <xsl:copy-of select="$html2"></xsl:copy-of>
+                                        </html2>
+                                    </xsl:if>
+                                    <xsl:call-template name="system_cache__appinfo:escaped_html_to_xml">
+                                        <xsl:with-param name="html" select="concat($TO_DELETE_STRING,$html2,$TO_DELETE_STRING)"/>
+                                        <xsl:with-param name="TO_DELETE_STRING" select="$TO_DELETE_STRING"/>
+                                    </xsl:call-template>
+                                </xsl:element>
+                            </xsl:otherwise>
+                        </xsl:choose>
+                        
                     </xsl:when>
                     <xsl:otherwise>
                         <xsl:message>#231 empty element for @* = <xsl:copy-of select="@*"/> problem for string like "{NAZWA_BAZY_DANYCH} &gt; {NAZWA_BAZY_DANYCH}.sql" (single lt; or rt character) testing this event (@2017-11-03)  </xsl:message>
@@ -417,10 +591,85 @@ W przypadku chęci ograniczenia w początkowej fazie wdrażania systemu jakości
                 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>
+                ">#543<xsl:value-of select="' '"/><xsl:value-of select="$anal_num_anal/anal_num_anal/gt[3]/text()"/></xsl:when>
         </xsl:choose>
     </xsl:template>
     
+    <!-- https://stackoverflow.com/questions/5372154/how-to-unescape-escaped-xml-content-with-the-help-of-xslt -->
+    <xsl:template name="unescapeattributes">
+        <xsl:param name="escapedattributes"/>
+        <xsl:variable name="attrname" select="substring-before($escapedattributes,'=')"/>
+        <xsl:variable name="attrquote" select="substring($escapedattributes,string-length($attrname)+2,1)"/>
+        <xsl:variable name="attrvalue" select="substring-before(substring-after($escapedattributes,$attrquote),$attrquote)"/>
+        <xsl:variable name="afterattr" select="substring-after(substring-after($escapedattributes,$attrquote),$attrquote)"/>
+        <xsl:choose>
+            <xsl:when test="$attrname = 'xmlns'">
+                <!--<xsl:namespace name="">
+                    <xsl:call-template name="unescapetext">
+                        <xsl:with-param name="escapedtext" select="$attrvalue"/>
+                    </xsl:call-template>
+                </xsl:namespace>-->
+            </xsl:when>
+            <xsl:when test="substring-before($attrname,':')='xmlns'"/>
+            <xsl:otherwise>
+                <xsl:attribute name="{$attrname}">
+                    <xsl:call-template name="unescapetext">
+                        <xsl:with-param name="escapedtext" select="$attrvalue"/>
+                    </xsl:call-template>
+                </xsl:attribute>
+            </xsl:otherwise>
+        </xsl:choose>
+        
+        <xsl:if test="contains($afterattr,'=')">
+            <xsl:call-template name="unescapeattributes">
+                <xsl:with-param name="escapedattributes" select="normalize-space($afterattr)"/>
+            </xsl:call-template>
+        </xsl:if>
+    </xsl:template>
+    
+    
+    <xsl:template name="unescapetext">
+        <xsl:param name="escapedtext"/>
+        <xsl:call-template name="string-replace-all">
+            <xsl:with-param name="text">
+                <xsl:call-template name="string-replace-all">
+                    <xsl:with-param name="text">
+                        <xsl:call-template name="string-replace-all">
+                            <xsl:with-param name="text" select="$escapedtext"/>
+                            <xsl:with-param name="replace">&amp;gt;</xsl:with-param>
+                            <xsl:with-param name="by">&gt;</xsl:with-param>
+                        </xsl:call-template>
+                    </xsl:with-param>
+                    <xsl:with-param name="replace">&amp;lt;</xsl:with-param>
+                    <xsl:with-param name="by">&lt;</xsl:with-param>
+                </xsl:call-template>
+            </xsl:with-param>
+            <xsl:with-param name="replace">&amp;amp;</xsl:with-param>
+            <xsl:with-param name="by">&amp;</xsl:with-param>
+        </xsl:call-template>
+    </xsl:template>
+    
+    
+    <!-- replaces substrings in strings -->
+    <xsl:template name="string-replace-all">
+        <xsl:param name="text"/>
+        <xsl:param name="replace"/>
+        <xsl:param name="by"/>
+        <xsl:choose>
+            <xsl:when test="contains($text, $replace)">
+                <xsl:value-of select="substring-before($text,$replace)"/>
+                <xsl:value-of select="$by"/>
+                <xsl:call-template name="string-replace-all">
+                    <xsl:with-param name="text" select="substring-after($text,$replace)"/>
+                    <xsl:with-param name="replace" select="$replace"/>
+                    <xsl:with-param name="by" select="$by"/>
+                </xsl:call-template>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:value-of select="$text"/>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:template>
     
     
 </xsl:stylesheet>