Sfoglia il codice sorgente

. sciezki i brakujace xsle - merge projekt ze schema by sie przydal!

a.binder 9 anni fa
parent
commit
11d86d281c

+ 2 - 2
SE/schema/ant-url_action/default_db.in7_dziennik_koresp/test-druk/IN7_DZIENNIK_KORESP.xsl

@@ -11,9 +11,9 @@
     <xsl:output indent="yes" />
     <xsl:strip-space elements="*"/>
     
-    <xsl:include href="../../WPS_Functions/DownloadProcesToDita/PROCES_INCLUDE.xsl"/>
-    
+    <!--<xsl:include href="../../WPS_Functions/DownloadProcesToDita/PROCES_INCLUDE.xsl"/>-->
     
+    <xsl:include href="PROCES_INCLUDE.xsl"/>
     
     <xsl:param name="dita_task_template_file_param" select="'main.dita'"/>
     <xsl:variable name="dita_task_template_file" select="doc($dita_task_template_file_param)"/>

+ 201 - 0
SE/schema/ant-url_action/default_db.in7_dziennik_koresp/test-druk/escaped_html_to_xml.xsl

@@ -0,0 +1,201 @@
+<?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: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,'&lt;') ">
+                    <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;')">
+                            <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&gt;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&gt;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()&gt;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&lt;=',$cur_pos,']/@level')" />-->
+                        <xsl:choose>
+                            <xsl:when test="sum($anal_num1/anal_num1/gt[number(@pos)&lt;= number($cur_pos) ]/@level)&lt;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)&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:choose>
+                        
+                        <xsl:copy-of select="@*"/>
+                        <xsl:value-of select="text()"/>
+                        <!--<copy>
+                            <xsl:copy-of select="$anal_num/anal_num/gt[  number(@pos)&lt;= 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)&gt;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)&gt;number(current()/@pos) and  number(@pos)&lt;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(.,'=&quot;')">
+                                            <e302><xsl:attribute name="val" select="."/>
+                                                <!--<xsl:attribute name="{.}" select="true()"/>-->
+                                                <xsl:for-each select="tokenize(.,'&quot;')">
+                                                    <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&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:choose>
+                                <xsl:when test="@element">&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: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:template>
+    
+    
+    
+</xsl:stylesheet>