Преглед изворни кода

merged xsl dita from schema and etc

a.binder пре 8 година
родитељ
комит
ca5d5f1a44

+ 5 - 0
SE/schema/default_db_xml_cache.public/build_ant_universal_by_xsl_match.xsl

@@ -32,6 +32,8 @@
     <!--<xsl:param name="external_schema_table.path" required="yes"/>-->
     
     
+    <xsl:param name="debug_level_param"/>
+
     <xsl:template mode="build_element_complexType.xml build_tr_map.xml" match="system_cache__appinfo:element_complexType"> <!-- for type generate in main build.xml mode -->
                 <project basedir="{$basedir}" name="{$antfile_prefix}" default="{$antfile_prefix}"
                     xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd">
@@ -88,7 +90,9 @@
             <param name="external_schema_table.path" >
                 <xsl:attribute name="expression" select="'${external_schema_table.path}'"/>
             </param>
+            <param name="debug_level_param" expression="{$debug_level_param}"/>
             <classpath location="/opt/local/share/java/saxon9he.jar"/>
+
         </xslt>
             <delete>
                 <xsl:attribute name="file" select="concat('${',with-param/@select,with-param/@name,'}')"/>
@@ -139,6 +143,7 @@
                 <param name="external_schema_table.path" >
                     <xsl:attribute name="expression" select="'${external_schema_table.path}'"/>
                 </param>
+                <param name="debug_level_param" expression="{$debug_level_param}"/>
                 <classpath location="/opt/local/share/java/saxon9he.jar"/>
             </xslt>
             <delete>

+ 55 - 9
SE/schema/default_db_xml_cache.public/build_object_install_se_ant_object.xsl

@@ -33,10 +33,23 @@
         </system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external>
     </xsl:template>
    
-    <xsl:template match="system_cache__appinfo:get_all_xsd|system_cache__appinfo:get_all_xsd_external_schema" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external"/>
+    <xsl:template match="system_cache__appinfo:get_all_xsd_external_schema" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external"/>
         
    
-    <xsl:template match="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external">
+    <xsl:template match="system_cache__appinfo:get_all_xsd[ schema/( 
+        @targetNamespace='http://biuro.biall-net.pl/xmlschema_procesy5/system_cache/graph_relation_elements.xsd' or
+        @targetNamespace='http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd' or
+        @targetNamespace='http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/p5_obj_vars.xsd'
+        or contains(@targetNamespace,'/default_db_xml_cache/')
+        or contains(@targetNamespace,'/system_cache/')
+        or contains(@targetNamespace,'/default_db/SystemObjects/')
+        ) or contains(@system_cache__appinfo:document-uri,'default_db_xml_cache.public/')]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:message>#44 bypassed @targetNamespace <xsl:value-of select="schema/@targetNamespace" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"/></xsl:message>
+    </xsl:template>
+   
+    
+   
+    <xsl:template match="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix|system_cache__appinfo:get_all_xsd[xs:schema/@targetNamespace='https://biuro.biall-net.pl/wfs/default_db/table/ADMIN_USERS.xsd']" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external">
         <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external">
             <xsl:with-param name="system_cache__appinfo:document-uri-orig" select="@system_cache__appinfo:document-uri-orig"/>
         </xsl:apply-templates>
@@ -131,9 +144,7 @@
             </xsl:variable>
             <xsl:copy-of select="$schema"/>
             <xsl:comment>#123 saving to <xsl:value-of select="concat($external_schema_table.path,'/',$system_cache__appinfo:document-uri-orig,'/',$schema.prefix,'.xsd')"/></xsl:comment>
-            <xsl:result-document href="{ concat($external_schema_table.path,'/',$system_cache__appinfo:document-uri-orig,'/',$schema.prefix,'.xsd')}">
-                <xsl:copy-of select="$schema"/>
-            </xsl:result-document>
+            
             
             <xsl:message>#135 ant-object install - todo dependency, than install </xsl:message>
             <xsl:for-each select="$schema/schema/element" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
@@ -402,7 +413,24 @@
     
     
     
-    <xsl:template match="element" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+    <xsl:template match="element|complexType[contains(@system_cache__appinfo:namespace_uri,$default_db_targetNamespace_detect_string)]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:param name="generate_tables_from_external_root.name" select="@name"/>
+        <xsl:param name="generate_tables_from_external_root.path" select="@name"/>
+        <xsl:param name="targetNamespace" required="yes"/>
+        <xsl:param name="prefix" required="yes"/>
+        <xsl:param name="prefix_root"  required="yes"/>
+        <xsl:param name="targetNamespace_root" required="yes"/>
+        
+        
+        <system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root>
+            <xsl:attribute name="generate_tables_from_external_root.name" select="$generate_tables_from_external_root.name"/>
+            <xsl:attribute name="generate_tables_from_external_root.path" select="$generate_tables_from_external_root.path"/>
+            <xsl:attribute name="prefix" select="$prefix"/>
+            <xsl:attribute name="targetNamespace" select="$targetNamespace"/>
+            <xsl:comment>#427 root element/complexType of $default_db_targetNamespace_detect_string(<xsl:value-of select="$default_db_targetNamespace_detect_string"/>) - we just copying without testing models in this @targetNamespace - To Be modified @2017-10-23</xsl:comment>
+            <xsl:copy-of select="."/>
+        </system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root>
+    </xsl:template><xsl:template match="element" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
         <xsl:param name="generate_tables_from_external_root.name" select="@name"/>
         <xsl:param name="generate_tables_from_external_root.path" select="@name"/>
         <xsl:param name="targetNamespace" required="yes"/>
@@ -543,7 +571,7 @@
         </system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root>
     </xsl:template>-->
     
-    <xsl:template match="complexType[complexType/@name]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+    <xsl:template match="complexType[complexType/@name and not( contains(@system_cache__appinfo:namespace_uri,$default_db_targetNamespace_detect_string))]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
         <xsl:param name="generate_tables_from_external_root.name" select="@name"/>
         <xsl:param name="generate_tables_from_external_root.path" select="@name"/>
         <xsl:param name="targetNamespace" required="yes"/>
@@ -776,7 +804,9 @@
     
     <xsl:template match="*|text()|comment()" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child.annotation" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"/>
     
-    <xsl:template match="annotation|appinfo" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child.annotation" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+    <xsl:template match="documentation" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child.annotation" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:copy-of select="."/>
+    </xsl:template><xsl:template match="annotation|appinfo" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child.annotation" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
         <xsl:param name="targetNamespace" required="yes"/>
         <xsl:param name="prefix" required="yes"/>
         <xsl:param name="prefix_root"  required="yes"/>
@@ -1185,7 +1215,23 @@
         </xsl:element>
     </xsl:template>
     
-    <xsl:template match="*" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_mktables">
+    <xsl:template match="element[ contains(.././@targetNamespace,$default_db_targetNamespace_detect_string)]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_mktables" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:element name="{name()}">
+            <xsl:copy-of select="../@*"/>
+            <xsl:copy-of select="@*"/>
+            <xsl:copy-of select="*"/>
+        </xsl:element>
+    </xsl:template>
+    
+    <xsl:template match="complexType[ contains(.././@targetNamespace,$default_db_targetNamespace_detect_string)]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_mktables" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:element name="{name()}">
+            <xsl:copy-of select="../@*"/>
+            <xsl:copy-of select="@*"/>
+            <xsl:copy-of select="*"/>
+        </xsl:element>
+    </xsl:template>
+    
+    <xsl:template match="*" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_mktables" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
         <xsl:param name="generate_tables_from_external_root.required_by.path_init"/>
         <xsl:element name="{name()}">
             <xsl:copy-of select="../@*"/>

+ 7 - 80
SE/schema/default_db_xml_cache.public/default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_tree_to_dita.xsl

@@ -289,28 +289,7 @@
                         </topichead>
                     </xsl:for-each-group>
                 </topichead>-->
-                <topichead navtitle="Powiązania do kontrahentów z którymi zawarto umowy (podział na źródła)(z wariantu porównawczego)">
-                    <xsl:for-each select="$sources/sources/source">
-                        <xsl:variable name="source" select="."/>
-                        <topichead navtitle="żródło: {.} - Powiązania do kontrahentów z którymi zawarto umowy">
-                            <xsl:for-each-group select="$resulset/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row[object[position() =  last()]/BI_audit_ENERGA_RUM_KONTRAHENCI and  object[position() = 1]/*/source= $source]" group-by="object[position() =  last()]/BI_audit_ENERGA_RUM_KONTRAHENCI/concat(ID,Pelna_nazwa_kontrahenta)">
-                                <xsl:variable name="group_name" select="object[position() = last() ]/* [ position() = 1]/system_cache__appinfo:truncate_special_and_do_uppercase(concat(ID,Pelna_nazwa_kontrahenta,position()))"/>
-                                
-                                <!--<topichead navtitle="{object[position() = last()]/*/concat(Pelna_nazwa_kontrahenta,' ',Miejscowosc,' ',NIP)} powiązań ({ count( current-group())}) ">-->
-                                <xsl:variable name="BI_audit_ENERGA_RUM_KONTRAHENCI.ID" select=" object[ position() = last()]/ BI_audit_ENERGA_RUM_KONTRAHENCI/ID"/>
-                                <xsl:choose>
-                                    <xsl:when test="//BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_old/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row/object[ position() = last()]/BI_audit_ENERGA_RUM_KONTRAHENCI/ID=$BI_audit_ENERGA_RUM_KONTRAHENCI.ID">
-                                        <xsl:apply-templates mode="BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_do" select="current-group()[position() = 1]">
-                                            <xsl:with-param name="group_name" select="$group_name"/>
-                                            <xsl:with-param name="BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA" select="$BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA"/>
-                                        </xsl:apply-templates> 
-                                    </xsl:when>
-                                </xsl:choose>
-                                <!--</topichead>-->
-                            </xsl:for-each-group>
-                        </topichead>
-                    </xsl:for-each>
-                </topichead>
+                
                 
                 
                 
@@ -467,68 +446,16 @@
                     
                 </topichead>
                 
-                <topichead navtitle="Powiązania do wybranych podmiotów/kontrahentów (dla wariantu porównawczego)">
-                    <xsl:for-each select="$sources/sources/source">
-                        <xsl:variable name="source" select="."/>
-                        <topichead navtitle="żródło: {.} -(podział na spółki własne)  Powiązania wybranych podmiotów/kontrahentów">
-                            
-                            <xsl:for-each-group select="$resulset/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_UMOWY" group-by="Spolka_glowna">
-                                <xsl:variable name="spolka_glowna" select="Spolka_glowna[1]"/>
-                                
-                                
-                                <xsl:variable name="if_topic">
-                                    <xsl:message>#268 if topic for <xsl:value-of select="$spolka_glowna"/>;</xsl:message>
-                                    <xsl:for-each-group select="$interested_row/interested_row/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row[object[position() =  last()]/BI_audit_ENERGA_RUM_KONTRAHENCI and  object[position() = 1]/*/source= $source]" group-by="object[position() =  last()]/BI_audit_ENERGA_RUM_KONTRAHENCI/concat(ID,Pelna_nazwa_kontrahenta)">
-                                        <xsl:variable name="group_name" select="object[position() = last() ]/* [ position() = 1]/system_cache__appinfo:truncate_special_and_do_uppercase(concat(ID,Pelna_nazwa_kontrahenta,position()))"/>
-                                        <xsl:variable name="kontrahent_id" select="object[position() = last() ]/BI_audit_ENERGA_RUM_KONTRAHENCI/ID"/>
-                                        <xsl:variable name="current_group" select="current-group()"/>
-                                        <!--<xsl:variable name="zrodlo" select="."/>-->
-                                        <xsl:message>#346 kontr podzial go <xsl:value-of select="position()"/> / id: <xsl:value-of select="$kontrahent_id"/> / <xsl:value-of select="$spolka_glowna"/></xsl:message>
-                                        <xsl:variable name="BI_audit_ENERGA_RUM_KONTRAHENCI.ID" select=" object[ position() = last()]/ BI_audit_ENERGA_RUM_KONTRAHENCI/ID"/>
-                                        <!--<topichead navtitle="{object[position() = last()]/*/concat(Pelna_nazwa_kontrahenta,' ',Miejscowosc,' ',NIP)} powiązań ({ count( current-group())}) ">-->
-                                        
-                                        <xsl:for-each select="$resulset/BI_audit_ENERGA_RUM_KONTRAHENCI[ID=$kontrahent_id and BI_audit_ENERGA_RUM_UMOWY/Spolka_glowna=$spolka_glowna]">
-                                            <xsl:if test="$interested_row/interested_row/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row/object[ position() = last()]/BI_audit_ENERGA_RUM_KONTRAHENCI[ID = $kontrahent_id]">
-                                                <topicref href="{$group_name}_DO/1.dita"/>
-                                            </xsl:if>
-                                            
-                                        </xsl:for-each>
-                                    </xsl:for-each-group>
-                                </xsl:variable>
+                
                                 
                                 <xsl:choose>
-                                    <xsl:when test="$if_topic/*">
-                                        <topichead navtitle="żródło: {$source} spółka gł:{$spolka_glowna} ">
-                                            <xsl:message>#267 podzial spolka glowna: <xsl:value-of select="$spolka_glowna"/></xsl:message>
-                                            <xsl:for-each-group select="$interested_row/interested_row/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row[object[position() =  last()]/BI_audit_ENERGA_RUM_KONTRAHENCI and  object[position() = 1]/*/source= $source]" group-by="object[position() =  last()]/BI_audit_ENERGA_RUM_KONTRAHENCI/concat(ID,Pelna_nazwa_kontrahenta)">
-                                                <xsl:variable name="group_name" select="object[position() = last() ]/* [ position() = 1]/system_cache__dita:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA.BI_audit_ENERGA_RUM_KONTRAHENCI.key(ID)"/>
-                                                <xsl:variable name="kontrahent_id" select="object[position() = last() ]/* [ position() = 1]/ID"/>
-                                                <xsl:variable name="current_group" select="current-group()"/>
-                                                <!--<xsl:variable name="zrodlo" select="."/>-->
-                                                
-                                                <xsl:variable name="BI_audit_ENERGA_RUM_KONTRAHENCI.ID" select=" object[ position() = last()]/ BI_audit_ENERGA_RUM_KONTRAHENCI/ID"/>
-                                                <!--<topichead navtitle="{object[position() = last()]/*/concat(Pelna_nazwa_kontrahenta,' ',Miejscowosc,' ',NIP)} powiązań ({ count( current-group())}) ">-->
-                                                
-
-                                                <xsl:for-each select="$resulset/BI_audit_ENERGA_RUM_KONTRAHENCI[ID=$kontrahent_id and BI_audit_ENERGA_RUM_UMOWY/Spolka_glowna=$spolka_glowna]">
-                                                    <xsl:message> #270 $kontrahent =<xsl:value-of select="$group_name"/></xsl:message>
-                                                    <xsl:if test="$interested_row/interested_row/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row/object[ position() = last()]/BI_audit_ENERGA_RUM_KONTRAHENCI[ID = $kontrahent_id]">
-                                                        <topicref href="{$group_name}/{$group_name}.dita"/>
-                                                    </xsl:if>
-                                                </xsl:for-each>
-                                                
-                                                <!--</topichead>-->
-                                            </xsl:for-each-group>
-
-                                        </topichead>
-                                    </xsl:when>
+                                    <xsl:when test="BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_old">
+                        <topichead navtitle="Powiązania dla wariantu porównawczego raportów (dostępne, nie użyte)"/>
+                    </xsl:when>
+                                            <xsl:otherwise><topichead navtitle="Powiązania dla wariantu porównawczego raportów  (niedostępne w danych do raportu)"/></xsl:otherwise>
                                 </xsl:choose>
                                 
-                            </xsl:for-each-group>
-
-                        </topichead>
-                    </xsl:for-each>
-                </topichead>
+                            
                 
                 <topichead navtitle="Powiązania do kontrahentów z KRS ogólnie (podział na źródła)">
                     

+ 330 - 0
SE/schema/default_db_xml_cache.public/default_db/Benford.xsl

@@ -0,0 +1,330 @@
+<?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:Benford="https://pl.wikipedia.org/wiki/Rozkład_Benforda"
+    xmlns:system_cache__dita="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/dita.xsd"
+    exclude-result-prefixes="xs"
+    version="2.0">
+    <!-- Template for analysis of https://pl.wikipedia.org/wiki/Rozkład_Benforda 
+        use this example to construct 
+        
+        
+        <Benford:table>
+           <xsl:attribute name="Benford:year" select="."/>
+           <xsl:attribute name="Benford:subject" select="$Osoba"/>
+               <xsl:for-each select="$BI_audit_ENERGA_RUM_UMOWY_fix//default_db:BI_audit_ENERGA_RUM_UMOWY[ lower-case(default_db:Osoba_merytoryczna___nazwisko_i_imie) = lower-case($Osoba)  and Data_zawarcia.rok = $rok_cur and not(Wartosc = '0' )]">
+                   <Benford:value><xsl:value-of select="substring( Wartosc,1,1)"/></Benford:value>
+               </xsl:for-each>
+        </Benford:table>
+        
+        than to analyze:
+        <xsl:if test="$Benford:table//Benford:value">
+            <xsl:apply-templates mode="Benford:table_analys" select="$Benford:table"/>
+        </xsl:if>
+        
+        expect:
+        
+        <Benford:table_analys_exceed Benford:year="2012"
+                                                  Benford:subject="Jan Npwak"
+                                                  Benford:digit="8"
+                                                  Benford:true.current.dig="5"
+                                                  Benford:current.dig.ratio="16"
+                                                  Benford:current.dig.test.fault="11"
+                                                  Benford:table_analys.dig.all.sum="37"/>
+                                                  
+          or:
+          
+         <Benford:table Benford:year="2011"
+              Benford:subject="Jan Nowak"
+              Benford:use_wider_period="#41 $Benford:table_analys not complete all numnbers used - use bigger period">
+                        <Benford:value>8</Benford:value>
+                        <Benford:value>5</Benford:value>
+                        <Benford:value>0</Benford:value>
+                        <Benford:value>0</Benford:value>
+                        <Benford:value>6</Benford:value>
+                        <Benford:value>0</Benford:value>
+                        <Benford:value>1</Benford:value>
+                        <Benford:value>1</Benford:value>
+                        <Benford:value>6</Benford:value>
+                        <Benford:value>8</Benford:value>
+                        <Benford:value>8</Benford:value>
+                        <Benford:value>8</Benford:value>
+                        <Benford:value>9</Benford:value>
+                        <Benford:value>0</Benford:value>
+                        <Benford:value>0</Benford:value>
+                        <Benford:value>6</Benford:value>
+                        <Benford:value>0</Benford:value>
+                        <Benford:value>0</Benford:value>
+                        <Benford:value>0</Benford:value>
+                        <Benford:value>0</Benford:value>
+                        <Benford:value>0</Benford:value>
+                     </Benford:table>
+        
+        which should be analyzed more wider - TODO example:
+    -->
+    
+    <xsl:param name="Benford:true.tolerance" select="10"/>
+    
+    <xsl:variable name="Benford:true">
+        <Benford:true>
+            <Benford:table_analys.dig Benford:digit="1" Benford:digit.occurs="{xs:double(30.1)}"/>
+            <Benford:table_analys.dig Benford:digit="2" Benford:digit.occurs="{xs:double(17.6)}"/>
+            <Benford:table_analys.dig Benford:digit="3" Benford:digit.occurs="{xs:double(12.5)}"/>
+            <Benford:table_analys.dig Benford:digit="4" Benford:digit.occurs="{xs:double(9.7)}"/>
+            <Benford:table_analys.dig Benford:digit="5" Benford:digit.occurs="{xs:double(7.9)}"/>
+            <Benford:table_analys.dig Benford:digit="6" Benford:digit.occurs="{xs:double(6.7)}"/>
+            <Benford:table_analys.dig Benford:digit="7" Benford:digit.occurs="{xs:double(5.8)}"/>
+            <Benford:table_analys.dig Benford:digit="8" Benford:digit.occurs="{xs:double(5.1)}"/>
+            <Benford:table_analys.dig Benford:digit="9" Benford:digit.occurs="{xs:double(4.6)}"/>
+        </Benford:true>
+    </xsl:variable>
+    
+    
+    
+    <xsl:template mode="Benford:table_analys" match="Benford:table">
+        <xsl:variable name="Benford:table" select="."/>
+        <!--<xsl:copy-of select="$Benford:table"></xsl:copy-of>-->
+        <xsl:variable name="Benford:table_analys">
+            <Benford:table_analys>
+                <xsl:copy-of select="@*"/>
+                <xsl:for-each select="1 to 9">
+                    <Benford:table_analys.dig>
+                        <xsl:attribute name="Benford:digit" select="."/>
+                        <xsl:attribute name="Benford:digit.occurs" select="count($Benford:table//Benford:value[ number(text()) = current()])"/>
+                    </Benford:table_analys.dig>
+                </xsl:for-each>
+            </Benford:table_analys>
+        </xsl:variable>
+        
+        <xsl:choose>
+            <xsl:when test="$Benford:table_analys//Benford:table_analys.dig[@Benford:digit.occurs = 0 ]">
+                <xsl:comment>#41 $Benford:table_analys not complete all numnbers used - use bigger period</xsl:comment>
+                <Benford:table>
+                    <xsl:copy-of select="$Benford:table/@*"/>
+                    <xsl:attribute name="Benford:use_wider_period" select="'#41 $Benford:table_analys not complete all numnbers used - use bigger period'"/>
+                    <xsl:copy-of select="*"/>
+                </Benford:table>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:variable name="Benford:table_analys.dig.all.sum" select="sum($Benford:table_analys//Benford:table_analys.dig/@Benford:digit.occurs)"/>
+                <xsl:for-each select="$Benford:table_analys//Benford:table_analys.dig">
+                    <xsl:variable name="Benford:true.current.dig" select="$Benford:true//Benford:table_analys.dig[number(@Benford:digit) = current()/number(@Benford:digit)]/@Benford:digit.occurs" />
+                    <xsl:variable name="Benford:current.dig.ratio" select="number(@Benford:digit.occurs) div number($Benford:table_analys.dig.all.sum) * 100" />
+                    <xsl:variable name="Benford:current.dig.test.fault" select="abs(number($Benford:current.dig.ratio) - number($Benford:true.current.dig))" />
+                    <xsl:choose>
+                        <xsl:when test=" number($Benford:current.dig.test.fault) &gt; number($Benford:true.tolerance) ">
+                            <Benford:table_analys_exceed>
+                                <xsl:copy-of select="$Benford:table/@*"/>
+                                <xsl:attribute name="Benford:digit" select="@Benford:digit"/>
+                                <xsl:attribute name="Benford:true.current.dig" select="round($Benford:true.current.dig)"/>
+                                <xsl:attribute name="Benford:current.dig.ratio" select="round($Benford:current.dig.ratio)"/>
+                                <xsl:attribute name="Benford:current.dig.test.fault" select="round($Benford:current.dig.test.fault)"/>
+                                <xsl:attribute name="Benford:table_analys.dig.all.sum" select="$Benford:table_analys.dig.all.sum"/>
+                                <xsl:attribute name="Benford:current.dig.test.fault.rel" select="number($Benford:current.dig.ratio) - number($Benford:true.current.dig)"/>
+                            </Benford:table_analys_exceed>
+                        </xsl:when>
+                    </xsl:choose>
+                </xsl:for-each>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:template>
+    
+    <xsl:template match="*|text()|comment()" mode="system_cache__dita:topic"/>
+    
+    <!-- to generate dita topic based on Benford:table_analys_exceed - it will try to target data from parameter (deals etc)-->
+    <xsl:template match="Benford:table_analys_exceed" mode="system_cache__dita:topic">
+        <!-- input: <Benford:table_analys_exceed Benford:year="2012"
+                                                  Benford:subject="Jan Npwak"
+                                                  Benford:digit="8"
+                                                  Benford:true.current.dig="5"
+                                                  Benford:current.dig.ratio="16"
+                                                  Benford:current.dig.test.fault="11"
+                                                  Benford:table_analys.dig.all.sum="37"
+                                                  Benford:current.dig.test.fault.rel="-10"/>
+        -->
+        <xsl:param name="Benford:subject.xml" /> <!-- example "$BI_audit_ENERGA_RUM_UMOWY_fix//default_db:BI_audit_ENERGA_RUM_UMOWY"  -->
+        <xsl:param name="Benford:subject.value" /> <!-- to search against Benford:subject.xml for get value - example  'Wartosc' -->
+        
+        <xsl:param name="Benford:subject" /> <!-- example to search against Benford:subject.xml 'default_db:Osoba_merytoryczna___nazwisko_i_imie'  -->
+        <xsl:param name="Benford:year" /> <!-- to search against shorter period - example  'Data_zawarcia.rok' -->
+        <xsl:param name="Benford:subject.description" /> <!-- to search against Benford:subject.xml for get description - example  'default_db:Przedmiot_umowy default_db:Kontrahenci' -->
+        
+        <xsl:param name="topic.id"/>
+        <xsl:param name="simpletable.id"/>
+        <xsl:param name="id" select="concat('topic__Benford_table_analys_exceed',generate-id())"/>
+        <xsl:variable name="Benford:table_analys_exceed" select="."/>
+        
+        <topic id="{$id}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            Benford:digit="{@Benford:digit}"
+            Benford:current.dig.test.fault="{@Benford:current.dig.test.fault}"
+            Benford:current.dig.test.fault.rel="{@Benford:current.dig.test.fault.rel}"
+            xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:topic.xsd">
+            
+            <xsl:message>#156 Wykryte anomalia Benford dla <xsl:value-of select="@Benford:subject"/> w <xsl:value-of select="@Benford:year"/> dla liczby <xsl:value-of select="@Benford:digit"/>  przekroczone o <xsl:value-of select="@Benford:current.dig.test.fault"/>, liczone dla <xsl:value-of select="@Benford:table_analys.dig.all.sum"/> pozycji.</xsl:message>
+            <xsl:choose>
+                <xsl:when test="$Benford:subject.xml and $Benford:subject.value "><!--<xsl:when test="$Benford:subject.xml and $Benford:subject and $Benford:year and $Benford:subject.value and $Benford:subject.description">-->
+                    <title>Wykryte anomalia Benford dla <xsl:value-of select="@Benford:subject"/> w <xsl:value-of select="@Benford:year"/> dla liczby <xsl:value-of select="@Benford:digit"/>   liczone dla <xsl:value-of select="@Benford:table_analys.dig.all.sum"/> pozycji.
+                        <!--Wartość: <xsl:value-of select="sum($Benford:subject.xml [ node()[name()=$Benford:subject] = $Benford:table_analys_exceed/@Benford:subject and substring(node()[name()=$Benford:subject.value],1,1)=$Benford:table_analys_exceed/@Benford:digit and  node()[name()=$Benford:year]=$Benford:table_analys_exceed/@Benford:year  ]/node()[name()=$Benford:subject.value])"/>-->
+                        Wartość: <xsl:value-of select="sum($Benford:subject.xml[substring(node()[name()=$Benford:subject.value],1,1)=$Benford:table_analys_exceed/@Benford:digit ] /node()[name()=$Benford:subject.value]) div 1000000"/> [mln]
+                        <xsl:if test="number(@Benford:current.dig.test.fault.rel) &lt; 0"> - Za mało obiektów o <xsl:value-of select="@Benford:current.dig.test.fault"/> %</xsl:if>
+                        <xsl:if test="number(@Benford:current.dig.test.fault.rel) &gt; 0"> - Przekroczenie ilości obiektów o <xsl:value-of select="@Benford:current.dig.test.fault"/> %</xsl:if>
+                    </title>
+                    <body>
+                        <p>
+                            <xsl:value-of select="@Benford:true.current.dig"/> - stała rozkładu dla  liczby <xsl:value-of select="@Benford:digit"/>.
+                        </p>
+                        <p>
+                            <xsl:value-of select="@Benford:current.dig.test.fault.rel"/> % - o ile za dużo / za mało jest danych
+                        </p>
+                        <p>
+                            <xsl:value-of select="round(sum($Benford:subject.xml/node()[name()=$Benford:subject.value]) div 1000000)"/> [mln] - ogólna wartość transakcji 
+                            
+                        </p>
+                        <p>
+                            <xsl:value-of select="count($Benford:subject.xml/node()[name()=$Benford:subject.value]) "/> -  ogólna ilość transakcji 
+                        </p>
+                        <p>
+                            <xsl:value-of select="round(sum($Benford:subject.xml[substring(node()[name()=$Benford:subject.value],1,1)=$Benford:table_analys_exceed/@Benford:digit ] /node()[name()=$Benford:subject.value]) div sum($Benford:subject.xml/node()[name()=$Benford:subject.value]) * 100 )"/> - % wartości trasnakcji z anomalią do ogółu (kwota) 
+                        </p>
+                        <p>
+                            <xsl:value-of select="count($Benford:subject.xml[substring(node()[name()=$Benford:subject.value],1,1)=$Benford:table_analys_exceed/@Benford:digit ] /node()[name()=$Benford:subject.value]) div count($Benford:subject.xml/node()[name()=$Benford:subject.value]) * 100 "/> -  % wartości trasnakcji z anomalią do ogółu (ilość) 
+                        </p>
+                        <simpletable frame="all"  relcolwidth="8* 1.0* 2*" id="topic__Benford_table_analys_exceed_simpletable_{ generate-id()}" > <!-- system_cache__dita:width_cols="auto" -->
+                            <sthead>
+                                <stentry>Dane obiektu </stentry>
+                                <stentry>Data</stentry>
+                                <stentry>Kwota</stentry>
+                            </sthead>
+                           
+                                <!--<xsl:for-each select="$Benford:subject.xml [ node()[name()=$Benford:subject] = $Benford:table_analys_exceed/@Benford:subject and substring(node()[name()=$Benford:subject.value],1,1)=$Benford:table_analys_exceed/@Benford:digit and  node()[name()=$Benford:year]=$Benford:table_analys_exceed/@Benford:year  ]">-->
+                                <xsl:for-each select="$Benford:subject.xml[substring(node()[name()=$Benford:subject.value],1,1)=$Benford:table_analys_exceed/@Benford:digit  ]">   
+                                    <strow>
+                                    <xsl:variable name="current" select="current()"/>
+                                        <stentry>
+                                            <!--<xsl:value-of select="current()/node()[name()='default_db:Numer_rejestrowy']"/>-->
+                                            <xsl:for-each select=" tokenize($Benford:subject.description,' ')">
+                                                <xsl:variable name="nname" select="."/>
+                                                <!--<xsl:comment>#171 checking for name '<xsl:value-of select="$nname"/>'</xsl:comment>-->
+                                                <p><xsl:value-of select="$nname"/>: <xsl:value-of select="$current//node()[name()=$nname]"/></p>
+                                            </xsl:for-each>
+                                        </stentry>
+                                        <stentry><xsl:value-of select="current()/node()[name()=$Benford:year]"/></stentry>
+                                        <stentry><xsl:value-of select="current()/node()[name()=$Benford:subject.value]"/></stentry>
+                                    </strow>
+                                </xsl:for-each>
+                            
+                        </simpletable>
+                    </body>
+                </xsl:when>
+                <xsl:when test="$topic.id and $simpletable.id">
+                    <title>Wykryte anomalia Benford dla <xsl:value-of select="@Benford:subject"/> w <xsl:value-of select="@Benford:year"/> dla liczby <xsl:value-of select="@Benford:digit"/>  przekroczone o <xsl:value-of select="@Benford:current.dig.test.fault"/>, liczone dla <xsl:value-of select="@Benford:table_analys.dig.all.sum"/> pozycji.</title>
+                    <body>
+                        <p><xsl:copy-of select="system_cache__dita:xref_2_topc($topic.id)"/></p>
+                    </body>
+                </xsl:when>
+            </xsl:choose>
+            
+        </topic>
+    </xsl:template>
+    
+    
+    <xsl:template match="topichead" mode="Benford:ditamap_root.embedded_map">
+        <xsl:apply-templates mode="Benford:ditamap_root.embedded_map"/>
+    </xsl:template>
+    
+    <xsl:template match="topic" mode="Benford:ditamap_root.embedded_map">
+        <xsl:message>#197 found topic <xsl:value-of select="@id"/></xsl:message>
+        <xsl:apply-templates mode="Benford:ditamap_root.embedded_map.topic">
+            <xsl:with-param name="topic.id" select="@id"/>
+        </xsl:apply-templates>
+    </xsl:template>
+    
+    <xsl:template match="body|p" mode="Benford:ditamap_root.embedded_map.topic">
+        <xsl:param name="topic.id" required="yes"/>
+        <xsl:apply-templates mode="Benford:ditamap_root.embedded_map.topic.body">
+            <xsl:with-param name="topic.id" select="$topic.id"/>
+        </xsl:apply-templates>
+    </xsl:template>
+    
+    <xsl:template match="simpletable" mode="Benford:ditamap_root.embedded_map.topic.body">
+        <xsl:param name="topic.id" required="yes"/>
+        <xsl:apply-templates mode="Benford:ditamap_root.embedded_map.topic.body.simpletable">
+            <xsl:with-param name="topic.id" select="$topic.id"/>
+            <xsl:with-param name="simpletable.id" select="@id"/>
+        </xsl:apply-templates>
+    </xsl:template>
+    
+    <xsl:template match="strow|stentry" mode="Benford:ditamap_root.embedded_map.topic.body.simpletable">
+        <xsl:param name="topic.id" required="yes"/>
+        <xsl:param name="simpletable.id" required="yes"/>
+        <xsl:apply-templates mode="Benford:ditamap_root.embedded_map.topic.body.simpletable">
+            <xsl:with-param name="topic.id" select="$topic.id"/>
+            <xsl:with-param name="simpletable.id" select="$simpletable.id"/>
+        </xsl:apply-templates>
+    </xsl:template>
+    
+    
+    
+    <xsl:template match="Benford:table_analys_exceed" mode="Benford:ditamap_root.embedded_map.topic.body.simpletable">
+        <xsl:param name="topic.id" required="yes"/>
+        <xsl:param name="simpletable.id" required="yes"/>
+        <xsl:apply-templates mode="system_cache__dita:topic" select=".">
+            <xsl:with-param name="topic.id" select="$topic.id"/>
+            <xsl:with-param name="simpletable.id" select="$simpletable.id"/>
+        </xsl:apply-templates>
+    </xsl:template>
+    
+    <xsl:template match="*" mode="Benford:ditamap_root.embedded_map">
+        <xsl:apply-templates mode="Benford:ditamap_root.embedded_map"/>
+    </xsl:template>
+    
+    <xsl:template match="text()|comment()" mode="Benford:ditamap_root.embedded_map"/>
+    
+    
+   
+    
+    <xsl:template match="*" mode="Benford:ditamap_root.embedded_map.body.topic.cleanup" >
+        <xsl:element name="{name()}">
+            <xsl:copy-of select="@*"/>
+            <xsl:apply-templates mode="Benford:ditamap_root.embedded_map.body.topic.cleanup"/>
+        </xsl:element>
+    </xsl:template>
+    
+    <xsl:template match="simpletable" mode="Benford:ditamap_root.embedded_map.body.topic.cleanup" >
+        <xsl:element name="{name()}">
+            <xsl:copy-of select="@*"/>
+            <xsl:apply-templates mode="Benford:ditamap_root.embedded_map.body.topic.cleanup.simpletable"/>
+        </xsl:element>
+    </xsl:template>
+    
+    <xsl:template match="strow|stentry|sthead|xref" mode="Benford:ditamap_root.embedded_map.body.topic.cleanup.simpletable" >
+        <xsl:element name="{name()}">
+            <xsl:copy-of select="@*"/>
+            <xsl:apply-templates mode="Benford:ditamap_root.embedded_map.body.topic.cleanup.simpletable"/>
+        </xsl:element>
+    </xsl:template>
+
+    <xsl:template match="topic" mode="Benford:ditamap_root.embedded_map.body.topic.cleanup.simpletable" >
+        <xsl:copy-of select="system_cache__dita:xref_2_topc(@id,concat('!(B',@Benford:digit,'/',round(@Benford:current.dig.test.fault.rel),')'))"/>
+    </xsl:template>
+    
+    
+    
+    <!--<xsl:template match="topic" mode="Benford:ditamap_root.embedded_map.body.topic.cleanup.simpletable"/>-->
+        
+    <xsl:template match="Benford:table|Benford:table_analys_exceed|Benford:value" mode="Benford:ditamap_root.embedded_map.body.topic.cleanup.simpletable" />
+    
+    
+    <xsl:template match="*" mode="Benford:ditamap_root.embedded_map.body.topicref.topic">
+        <xsl:for-each select=".//topic">
+            <xsl:apply-templates select="." mode="system_cache__dita:xref.topic.result-document"/>
+        </xsl:for-each>
+    </xsl:template>
+    
+    <xsl:template mode="ditamap_root.embedded_map.body" match="@Benford:value"/>
+    <xsl:template mode="system_cache__dita:xref.topic.result-document" match="@Benford:digit"/>
+    <xsl:template mode="system_cache__dita:xref.topic.result-document" match="@Benford:current.dig.test.fault|@Benford:current.dig.test.fault.rel"/>
+    
+    <!--<xsl:template mode="table_cut" match="@Benford:value" />-->
+    
+</xsl:stylesheet>

+ 477 - 13
SE/schema/default_db_xml_cache.public/default_db/tree_to_dita.xsl

@@ -138,13 +138,15 @@
     
     
     
+    <xsl:include href="Benford.xsl"/>
     <xsl:output indent="yes"/>
     <xsl:strip-space elements="*"/>
     
     <xsl:param name="temp" required="yes"/>
     <xsl:param name="uuid" required="yes"/>
     
-    <xsl:variable name="ditadir" select="concat($temp,'/',$uuid)"/>
+    <xsl:param name="system_cache__dita:pdf_a4_string_width" select="80"/> <!-- parameter for automate table width - how many letters fits in pdf output -->
+    <xsl:param name="system_cache__dita:simpletable.col.size" select="4"/><xsl:variable name="ditadir" select="concat($temp,'/',$uuid)"/>
     
     <xsl:template mode="preprocess" match="RelatedFeatureRoot">
         <preprocess_dita>
@@ -188,26 +190,40 @@
     <xsl:template match="map" mode="ditamap_root">
         <xsl:element name="{name()}">
             <xsl:copy-of select="@*"/>
-        <xsl:apply-templates mode="ditamap_root.embedded_map" />
+        <xsl:copy-of select="title"/><xsl:apply-templates mode="ditamap_root.embedded_map" />
+        <xsl:message>#196 in mode="ditamap_root" digging! </xsl:message></xsl:element>
+    </xsl:template>
+    
+    <xsl:template match="topichead|xref" mode="ditamap_root.embedded_map">
+        <xsl:element name="{name()}">
+            <xsl:copy-of select="@*"/>
+            <xsl:apply-templates mode="ditamap_root.embedded_map" />
         </xsl:element>
     </xsl:template>
     
-    <xsl:template match="topic" mode="ditamap_root.embedded_map">
+    <xsl:template mode="ditamap_root.embedded_map" match="@*"><xsl:copy-of select="."/></xsl:template><xsl:template match="topic" mode="ditamap_root.embedded_map">
         <topicref href="{@id}.dita">
-            <xsl:result-document href="{$temp}/{$uuid}/{@id}.dita">
+            <xsl:variable name="ditamap_root.embedded_map.body">
+                <xsl:apply-templates mode="ditamap_root.embedded_map.body"/>
+            </xsl:variable><xsl:result-document href="{$temp}/{$uuid}/{@id}.dita">
                 <xsl:element name="{name()}">
-                    <xsl:copy-of select="@*"/>
-                    <xsl:apply-templates mode="ditamap_root.embedded_map.body"/>
+                    <xsl:apply-templates mode="ditamap_root.embedded_map" select="@*"/>
+                    <!--<xsl:copy-of select="@*"/>-->
+                    <xsl:apply-templates mode="Benford:ditamap_root.embedded_map.body.topic.cleanup" select="$ditamap_root.embedded_map.body"/>
                 </xsl:element>
             </xsl:result-document>
-            <xsl:apply-templates mode="ditamap_root.embedded_map" />
+            <xsl:apply-templates mode="Benford:ditamap_root.embedded_map.body.topicref.topic" select="$ditamap_root.embedded_map.body"/><xsl:apply-templates mode="ditamap_root.embedded_map" />
         </topicref>
     </xsl:template>
     
     
-    <xsl:template match="*" mode="ditamap_root.embedded_map.body">
+    <xsl:template mode="ditamap_root.embedded_map.body" match="@*">
+        <xsl:copy-of select="."/>
+    </xsl:template>
+    
+    <xsl:template mode="ditamap_root.embedded_map.body" match="@system_cache__dita:width_cols"/><xsl:template match="*" mode="ditamap_root.embedded_map.body">
         <xsl:element name="{name()}">
-            <xsl:copy-of select="@*"/>
+            <xsl:apply-templates select="@*" mode="ditamap_root.embedded_map.body"/>
             <xsl:apply-templates mode="ditamap_root.embedded_map.body"/>
         </xsl:element>
     </xsl:template>
@@ -228,14 +244,63 @@
     </xsl:template>
     
     
-    <xsl:template match="*" mode="preprocess_root.embedded_map.simpletable">
+    <xsl:template match="simpletable[ count(sthead/stentry) &gt; 6 ]" mode="ditamap_root.embedded_map.body">
+        <xsl:variable name="system_cache__dita:max_strings">
+            <xsl:call-template name="system_cache__dita:max_strings">
+                <xsl:with-param name="simpletable" select="."/>
+            </xsl:call-template>
+        </xsl:variable>
+        <!--<debug_Max>
+            <xsl:copy-of select="$system_cache__dita:max_strings"/>
+        </debug_Max>-->
+        <xsl:variable name="width_cols">
+            <xsl:choose>
+                <xsl:when test="@system_cache__dita:width_cols='auto'">
+                    <xsl:call-template name="system_cache__dita:width_cols.auto">
+                        <xsl:with-param name="simpletable" select="."/>
+                        <xsl:with-param name="max_strings" select="$system_cache__dita:max_strings"/>
+                    </xsl:call-template>
+                </xsl:when>
+                <xsl:when test="@system_cache__dita:width_cols"><xsl:value-of select="@system_cache__dita:width_cols"/></xsl:when>
+                <xsl:otherwise><xsl:value-of select="6"/></xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
+        <xsl:variable name="header_cols">
+            <xsl:choose>
+                <xsl:when test="@system_cache__dita:header_cols"><xsl:value-of select="@system_cache__dita:width_cols"/></xsl:when>
+                <xsl:otherwise><xsl:value-of select="1"/></xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
+        <!--<xsl:variable name="header_cols.relcolwidth">
+            <xsl:choose>
+                <xsl:when test="@system_cache__dita:header_cols.relcolwidth"><xsl:value-of select="@system_cache__dita:header_cols.relcolwidth"/></xsl:when>
+                <xsl:otherwise><xsl:value-of select="'2*'"/></xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>-->
+        <xsl:variable name="table_cut">
+            <xsl:apply-templates select="." mode="table_cut">
+                <xsl:with-param name="width_cols"  select="xs:integer($width_cols)"/>
+                <xsl:with-param name="header_cols" select="xs:integer($header_cols)"/>
+                <xsl:with-param name="start_row"  select="1"/>
+                <xsl:with-param name="start_col"  select="1"/>
+                <!--<xsl:with-param name="header_cols.relcolwidth"  select="$header_cols.relcolwidth"/>-->
+                <xsl:with-param name="max_strings" select="$system_cache__dita:max_strings"/>
+            </xsl:apply-templates>
+        </xsl:variable>
+        <xsl:message>#308 debug @topic.id=<xsl:value-of select="../../../@id"/> ;</xsl:message>
+        <xsl:apply-templates mode="table_cut.local_xref" select="$table_cut">
+            <xsl:with-param name="header_cols" select="xs:integer($header_cols)"/>
+            <xsl:with-param name="topic.id" select="../../../@id"/>
+        </xsl:apply-templates>
+        <!--<xsl:copy-of select="$table_cut"/>-->
+    </xsl:template><xsl:template match="*" mode="preprocess_root.embedded_map.simpletable">
         <xsl:element name="{name()}">
             <xsl:copy-of select="@*"/>
             <xsl:apply-templates mode="preprocess_root.embedded_map.simpletable"/>
         </xsl:element>
     </xsl:template>
     <xsl:template match="@*" mode="preprocess_root.embedded_map.simpletable">
-        <xsl:copy-of select="@*"/>
+        <xsl:copy-of select="."/>
     </xsl:template>
     
     <xsl:template match=" text()" mode="preprocess_root.embedded_map.simpletable">
@@ -277,8 +342,407 @@
     
   
     
-    <xsl:template match="*|text()|comment()" mode="ditamap_root.embedded_map"/>
+    <xsl:template mode="table_cut" match="simpletable">
+        <xsl:param name="width_cols"  select="6"/>
+        <xsl:param name="header_cols" select="1"/>
+        <xsl:param name="start_row"  select="1"/>
+        <xsl:param name="start_col"  select="1"/>
+        <!--<xsl:param name="header_cols.relcolwidth" required="yes"/>-->
+        <xsl:param name="max_strings" required="yes"/>
+        <xsl:variable name="simpletable" select="."/>
+        <xsl:variable name="to" select="ceiling((count(sthead/stentry) - $header_cols ) div ( $width_cols + $header_cols ) )"/>
+        <xsl:variable name="to" >
+            <xsl:choose>
+                <xsl:when test="count(sthead/stentry) mod $width_cols = 1">
+                    <xsl:value-of select="$to"/>
+                </xsl:when>
+                <xsl:when test="count(sthead/stentry) mod $width_cols &gt; 1">
+                    <xsl:value-of select="$to "/> <!-- + 1 -->
+                    <!--<xsl:message>#383 table @id=<xsl:value-of select="@id"/> count(sthead/stentry) mod $width_cols &gt; 1</xsl:message>-->
+                </xsl:when>
+                <xsl:otherwise><xsl:value-of select="$to"/></xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
+        <xsl:message>#306 strip table @id=<xsl:value-of select="@id"/>; 1 to <xsl:value-of select="$to"/>; (width_cols = <xsl:value-of select="$width_cols"/>) ; count(sthead/stentry)=<xsl:value-of select="count(sthead/stentry)"/>; </xsl:message>
+        
+        <xsl:for-each select="1 to xs:integer($to) ">
+            <xsl:if test="xs:integer($to) &gt; 1">
+                Tabela podzielona - część <xsl:value-of select="position()"/>/<xsl:value-of select="xs:integer($to)"/>.
+            </xsl:if>
+            <xsl:apply-templates mode="table_cut.strow" select="$simpletable">
+                <xsl:with-param name="width_cols"  select="$width_cols"/>
+                <xsl:with-param name="header_cols" select="$header_cols"/>
+                <xsl:with-param name="start_row"  select="$start_row"/>
+                <xsl:with-param name="start_col"  select="current() * $width_cols - $width_cols + 1"/>
+                <!--<xsl:with-param name="header_cols.relcolwidth"  select="$header_cols.relcolwidth"/>-->
+                <xsl:with-param name="position" select="position()"/>
+                <xsl:with-param name="max_strings" select="$max_strings"/>
+            </xsl:apply-templates>
+        </xsl:for-each>
+    </xsl:template>
+    
+    <xsl:template mode="table_cut" match="@id">
+        <xsl:param name="start_col" required="yes"/>
+        <xsl:attribute name="id" select=" concat(.,'_',$start_col)"/>
+    </xsl:template>
+    <xsl:template mode="table_cut" match="@*">
+        <xsl:copy-of select="."/>
+    </xsl:template>
     
+    <xsl:template mode="table_cut" match="@system_cache__dita:width_cols" />
+    <xsl:template mode="table_cut" match="@system_cache__dita:bypass_rows_with_zero" />
+    <xsl:template mode="table_cut" match="@system_cache__dita:bypass_rows_empty" />
+    <xsl:template mode="table_cut.local_xref" match="@system_cache__dita:position"/>
+    <xsl:template mode="table_cut.local_xref" match="@*"><xsl:copy-of select="."/></xsl:template>
+    
+    <xsl:template name="system_cache__dita:header_cols.relcolwidth"  >
+        <xsl:param name="cols_count" required="yes"/>
+        <xsl:param name="header_cols" required="yes"/>
+        <xsl:param name="max_strings" required="yes"/>
+        <xsl:param name="system_cache__dita:header_cols.relcolwidth"/> <!-- to be set from attribute optionaly -->
+        <xsl:message>#372 @id=<xsl:value-of select=".././@id"/> @system_cache__dita:header_cols.relcolwidth run. $cols_count=<xsl:value-of select="$cols_count"/>; $header_cols=<xsl:value-of select="$header_cols"/>;</xsl:message>
+        <xsl:attribute name="relcolwidth">
+            <!--<xsl:value-of select="concat($cols_count,'_',.)"/>-->
+            <xsl:for-each select="1 to $cols_count">
+                <xsl:choose>
+                    <xsl:when test=" current() &lt;= $header_cols and $system_cache__dita:header_cols.relcolwidth">
+                        <xsl:value-of select="$system_cache__dita:header_cols.relcolwidth"/><xsl:text> </xsl:text>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="concat(ceiling($max_strings//stentry[@pos = current()]/@max.string.ph.len.max),'*')"/>
+                        <xsl:choose>
+                            <xsl:when test="current() = $cols_count"></xsl:when>
+                            <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
+                        </xsl:choose>
+                    </xsl:otherwise>
+                </xsl:choose>
+            </xsl:for-each>
+        </xsl:attribute>
+    </xsl:template>
+
+    <xsl:template mode="table_cut" match="@system_cache__dita:header_cols.relcolwidth" >
+        <xsl:param name="cols_count" required="yes"/>
+        <xsl:param name="header_cols" required="yes"/>
+        <xsl:param name="max_strings" required="yes"/>
+        <xsl:call-template name="system_cache__dita:header_cols.relcolwidth">
+            <xsl:with-param name="max_strings" select="$max_strings"/>
+            <xsl:with-param name="header_cols" select="$header_cols"/>
+            <xsl:with-param name="cols_count" select="$cols_count"/>
+            <xsl:with-param name="system_cache__dita:header_cols.relcolwidth" select="@system_cache__dita:header_cols.relcolwidth"/>
+        </xsl:call-template>
+    </xsl:template>
     
     
-</xsl:stylesheet>
+    <xsl:template mode="table_cut.strow" match="simpletable">
+        <xsl:param name="width_cols" required="yes"/>
+        <xsl:param name="header_cols" required="yes"/>
+        <xsl:param name="start_row"   required="yes"/>
+        <xsl:param name="start_col"   required="yes"/>
+        <!--<xsl:param name="header_cols.relcolwidth"  required="yes"/>-->
+        <xsl:param name="position"  required="yes"/>
+        <xsl:param name="max_strings" required="yes"/>
+        <xsl:variable name="simpletable" select="."/>
+        <xsl:variable name="simpletable.id" select="concat($uuid,'_',@id,'_',$start_col)"/>
+        <xsl:message>#325 starting $start_col=<xsl:value-of select="$start_col"/>;</xsl:message>
+        <xsl:variable name="add_to_once" select="$position">
+            <!--<xsl:choose>
+                <xsl:when test="$start_col = 1"><xsl:value-of select="xs:integer(0)"/></xsl:when>
+                <xsl:otherwise><xsl:value-of select="xs:integer(1)"/></xsl:otherwise>
+            </xsl:choose>-->
+        </xsl:variable>
+        
+        <xsl:variable name="cols_count" > <!--  select="$header_cols - 1 + $start_col + $header_cols  - $start_col + $header_cols + $width_cols" -->
+            <!--<xsl:choose>
+                        <xsl:when test="count(sthead/stentry) &lt;= $width_cols"><xsl:value-of select="count(sthead/stentry)"/></xsl:when>
+                        <xsl:when test="count(sthead/stentry) &lt;= $width_cols"><xsl:value-of select="count(sthead/stentry)"/></xsl:when>
+                    </xsl:choose>-->
+            <xsl:choose>
+                <xsl:when test="count(sthead/stentry) &lt;= $width_cols"><!--  mniejsza tabela niz width -->
+                    <xsl:message>#386a mniejsza tabela niz width - set <xsl:value-of select="count(sthead/stentry)"/></xsl:message>
+                    <xsl:value-of select="count(sthead/stentry)"/>
+                </xsl:when>
+                <xsl:when test="$start_col = 1 and count(sthead/stentry) &gt;= $width_cols  "> <!--  poczatek duzej tabeli -->
+                    <xsl:message>#386d $width_cols=<xsl:value-of select="$width_cols"/>;  $start_col=<xsl:value-of select="$start_col"/>; cnt<xsl:value-of select="count(sthead/stentry)"/>; poczatek duzej tabeli - set <xsl:value-of select="$header_cols + $width_cols + 1"/></xsl:message>
+                    <xsl:value-of select="$header_cols + $width_cols + 1"/>
+                </xsl:when>
+                <xsl:when test="count(sthead/stentry) - $start_col + $position &lt;= $width_cols + $position "> <!--  koncowka duzej tabeli -->
+                    <xsl:message>#386c $width_cols=<xsl:value-of select="$width_cols"/>;  $start_col=<xsl:value-of select="$start_col"/>; cnt<xsl:value-of select="count(sthead/stentry)"/>; koncowka duzej tabeli - set <xsl:value-of select="count(sthead/stentry) - $start_col - $position + $header_cols "/></xsl:message>
+                    <xsl:value-of select="count(sthead/stentry) - $start_col - $position + $header_cols "/>
+                </xsl:when>
+                <xsl:when test="count(sthead/stentry) - $start_col &gt; $width_cols "> <!--  srodek duzej tabeli -->
+                    <xsl:message>#386b $width_cols=<xsl:value-of select="$width_cols"/>; $start_col=<xsl:value-of select="$start_col"/>; cnt<xsl:value-of select="count(sthead/stentry)"/>; srodek duzej tabeli - set <xsl:value-of select="$width_cols + $header_cols "/></xsl:message>
+                    <xsl:value-of select="$width_cols + $header_cols + 1"/>
+                </xsl:when>
+                <xsl:otherwise>
+                    <xsl:message terminate="yes">#386c $width_cols=<xsl:value-of select="$width_cols"/>; $start_col=<xsl:value-of select="$start_col"/>; cnt<xsl:value-of select="count(sthead/stentry)"/>; blad warunku tabeli </xsl:message>
+                </xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
+        
+        <xsl:element name="{name()}">
+            <xsl:attribute name="system_cache__dita:position" select="$position"/>
+            <xsl:apply-templates mode="table_cut" select="@*">
+                <xsl:with-param name="header_cols" select="$header_cols"/>
+                <xsl:with-param name="start_col" select="$start_col"/>
+                <!--<xsl:with-param name="header_cols.relcolwidth"  select="$header_cols.relcolwidth"/>-->
+                <xsl:with-param name="max_strings" select="$max_strings"/>
+                <xsl:with-param name="cols_count" select="$cols_count" /> 
+            </xsl:apply-templates>
+            <xsl:if test="not(@system_cache__dita:header_cols.relcolwidth)"><!-- force to use auto relcolwidth -->
+                    <xsl:call-template name="system_cache__dita:header_cols.relcolwidth">
+                        <xsl:with-param name="max_strings" select="$max_strings"/>
+                        <xsl:with-param name="cols_count" select="$cols_count" />
+                        <xsl:with-param name="header_cols" select="$header_cols"/>
+                    </xsl:call-template>
+                </xsl:if>
+                <xsl:if test="$start_row = 1">
+                    <sthead>
+                        <xsl:for-each select="1 to $header_cols"><!-- naglowki -->
+                            <stentry><xsl:value-of select="$simpletable/sthead/stentry[ position() = current()]"/></stentry>
+                        </xsl:for-each>
+                        <xsl:for-each select="$start_col + $header_cols + xs:integer($add_to_once) to $start_col + $header_cols + $width_cols + xs:integer($add_to_once)">
+                            <xsl:if test="$simpletable/sthead/stentry[ position() = current()]">
+                                <stentry><xsl:value-of select="$simpletable/sthead/stentry[ position() = current()]"/></stentry>
+                            </xsl:if>
+                        </xsl:for-each>
+                    </sthead>
+                </xsl:if>
+                <xsl:variable name="strow_test.root">
+                    <xsl:for-each select="strow">
+                        <xsl:variable name="strow" select="."/> 
+                        <xsl:variable name="simpletable.id" select="concat($simpletable.id,'_h_',position())"/>
+                        
+                        <xsl:variable name="strow_test">
+                            <strow>
+                                <xsl:attribute name="id" select="$simpletable.id"/>
+                            <!--<xsl:for-each select="1 to $header_rows"><!-\- wart -\->
+                                <stentry><xsl:value-of select="$strow/strow[ position() = current()]"/></stentry>
+                            </xsl:for-each>-->
+                                <xsl:for-each select="1 to $header_cols">
+                                     <xsl:if test="$strow/stentry[ position() = current()]">
+                                         <stentry id="{$simpletable.id}_h{position()}"><xsl:value-of select="$strow/stentry[ position() = current()]/text()"/></stentry>
+                                     </xsl:if>
+                                 </xsl:for-each>
+                                <xsl:for-each select="$start_col + $header_cols + xs:integer($add_to_once) to  $start_col + $header_cols + $width_cols  + xs:integer($add_to_once)">
+                                    <xsl:if test="$simpletable/sthead/stentry[ position() = current()]">
+                                        <stentry id="{$simpletable.id}_e{position()}"><xsl:value-of select="$strow/stentry[ position() = current()]/text()"/>
+                                            <xsl:copy-of select="$strow/stentry[ position() = current()]/Benford:table_analys_exceed"/>
+                                            <xsl:copy-of select="$strow/stentry[ position() = current()]/Benford:table"/>
+                                            <xsl:copy-of select="$strow/stentry[ position() = current()]/topic"/>
+                                        </stentry>
+                                    </xsl:if>
+                                </xsl:for-each>
+                            </strow>
+                        </xsl:variable>
+                        <!-- handle system_cache__dita:bypass_rows_with_zero="true" system_cache__dita:bypass_rows_empty="true" -->
+                        
+                        <!--<xsl:message>#547 $simpletable/@system_cache__dita:bypass_rows_with_zero  - <xsl:value-of select="$simpletable/@system_cache__dita:bypass_rows_with_zero"/> ; <xsl:value-of select="$strow_test/stentry[ position() &gt; $header_cols and not( text()='0')]"/></xsl:message>-->
+                        
+                        <xsl:choose>
+                            <xsl:when test="$simpletable/@system_cache__dita:bypass_rows_empty and $simpletable/@system_cache__dita:bypass_rows_with_zero and $strow_test//stentry[ position() &gt; $header_cols and ( text() and not( text()='0')  )]">
+                                <xsl:comment>#549c not ignored @system_cache__dita:bypass_rows_empty and @system_cache__dita:bypass_rows_with_zero </xsl:comment>
+                                <xsl:message>#549c not ignored @system_cache__dita:bypass_rows_empty and @system_cache__dita:bypass_rows_with_zero </xsl:message>
+                                <xsl:copy-of select="$strow_test"/>
+                            </xsl:when>
+                            <xsl:when test="$simpletable/@system_cache__dita:bypass_rows_with_zero and not($simpletable/@system_cache__dita:bypass_rows_empty) and $strow_test//stentry[ position() &gt; $header_cols and  not( text()='0' )  ]">
+                                <xsl:comment>#549a not ignored @system_cache__dita:bypass_rows_with_zero  </xsl:comment>
+                                <xsl:message>#549a not ignored @system_cache__dita:bypass_rows_with_zero <xsl:value-of select="$strow_test//stentry[ position() &gt; $header_cols and not( text()='0')]"/> </xsl:message>
+                                <xsl:copy-of select="$strow_test"/>
+                            </xsl:when>
+                            <xsl:when test="$simpletable/@system_cache__dita:bypass_rows_empty and not($simpletable/@system_cache__dita:bypass_rows_with_zero ) and $strow_test//stentry[ position() &gt; $header_cols and  text() ]">
+                                <xsl:comment>#549b not ignored @system_cache__dita:bypass_rows_empty  </xsl:comment>
+                                <xsl:message>#549b not ignored @system_cache__dita:bypass_rows_empty <xsl:value-of select="$strow_test//stentry[ position() &gt; $header_cols and text() ]"/> </xsl:message>
+                                <xsl:copy-of select="$strow_test"/>
+                            </xsl:when>
+                            <xsl:when test="$simpletable/@system_cache__dita:bypass_rows_with_zero or $simpletable/@system_cache__dita:bypass_rows_empty"> <!-- or $simpletable/@system_cache__dita:bypass_rows_with_zero  -->
+                                <xsl:comment>#549d ignored @system_cache__dita:bypass_rows_empty  </xsl:comment>
+                                <xsl:message>#549d ignored @system_cache__dita:bypass_rows_empty  </xsl:message>
+                            </xsl:when>
+                            <xsl:otherwise><xsl:copy-of select="$strow_test"/></xsl:otherwise>
+                        </xsl:choose>
+                    </xsl:for-each>
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="$strow_test.root//strow">
+                        <xsl:copy-of select="$strow_test.root"/>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <strow>
+                            <xsl:for-each select="strow[1]">
+                                <xsl:variable name="strow" select="."/> 
+                                <xsl:variable name="simpletable.id" select="concat($simpletable.id,'_h_',position())"/>
+                                <xsl:for-each select="1 to $header_cols">
+                                     <xsl:if test="$strow/stentry[ position() = current()]">
+                                         <stentry id="{$simpletable.id}_h{position()}">(pominięto)</stentry>
+                                     </xsl:if>
+                                 </xsl:for-each>
+                                 <xsl:for-each select="$start_col + $header_cols + xs:integer($add_to_once) to  $start_col + $header_cols + $width_cols  + xs:integer($add_to_once)">
+                                     <xsl:if test="$simpletable/sthead/stentry[ position() = current()]">
+                                         <stentry id="{$simpletable.id}_e{position()}">0</stentry>
+                                     </xsl:if>
+                                 </xsl:for-each>
+                             </xsl:for-each>
+                        </strow>
+                    </xsl:otherwise>
+                </xsl:choose>
+        </xsl:element>
+    </xsl:template>
+  
+    <xsl:template name="system_cache__dita:max_strings">
+        <xsl:param name="simpletable" required="yes"/>
+        <xsl:variable name="max_strings">
+            <max_strings>
+                <xsl:for-each select="$simpletable/sthead/stentry">
+                    <stentry>
+                        <xsl:attribute name="pos" select="position()"/>
+                        <xsl:attribute name="len" select="string-length( text())"/>
+                        <xsl:attribute name="string.ph.len.max" select="system_cache__dita:string.ph.len.max( text())"/>
+                    </stentry>
+                    <xsl:variable name="pos" select="position()"/>
+                    <xsl:for-each select="$simpletable/strow">
+                        <xsl:for-each select="stentry[ position() = $pos]">
+                            <stentry>
+                                <xsl:attribute name="pos" select="$pos"/>
+                                <xsl:attribute name="stentry" select="'tak'"/>
+                                <xsl:attribute name="len" select="string-length( text())"/>
+                                <xsl:attribute name="string.ph.len.max" select="system_cache__dita:string.ph.len.max( text())"/>
+                            </stentry>
+                        </xsl:for-each>
+                    </xsl:for-each>
+                </xsl:for-each>
+            </max_strings>
+        </xsl:variable>
+        
+        <xsl:variable name="max_strings">
+            <max_strings><!--<xsl:comment><xsl:copy-of select="$max_strings"/></xsl:comment>-->
+                <xsl:for-each-group select="$max_strings//stentry" group-by="@pos">
+                    <stentry>
+                        <xsl:attribute name="pos" select="@pos"/>
+                        <xsl:attribute name="max.len" select="max( current-group()/@len )"/>
+                        <xsl:attribute name="max.string.ph.len.max" select="max( current-group()/@string.ph.len.max )"/>
+                    </stentry>
+                </xsl:for-each-group>
+            </max_strings>
+        </xsl:variable>
+        <xsl:copy-of select="$max_strings"/>
+    </xsl:template>
+  
+  
+    <xsl:template name="system_cache__dita:width_cols.auto">
+        <xsl:param name="simpletable" required="yes"/><!-- detect optimal table width_cols -->
+        <xsl:param name="max_strings" required="yes"/>
+        <xsl:variable name="sum_width" select="sum($max_strings//@max.string.ph.len.max) + $system_cache__dita:simpletable.col.size * count($max_strings//stentry) "/>
+        <xsl:variable name="screens_div_sum" select="$system_cache__dita:pdf_a4_string_width div $sum_width"/>
+        <xsl:variable name="system_cache__dita:width_cols.auto.cols" select="count($simpletable/sthead/stentry) * $screens_div_sum"/>     
+        <xsl:variable name="system_cache__dita:width_cols.auto.div" select=" ceiling(count($simpletable/sthead/stentry) div $system_cache__dita:width_cols.auto.cols)"/>
+        <xsl:variable name="system_cache__dita:width_cols.auto" select="round(count($simpletable/sthead/stentry) div $system_cache__dita:width_cols.auto.div )"/>
+        <xsl:message>#506 system_cache__dita:width_cols.auto $sum_width=<xsl:value-of select="$sum_width"/> $screens_div_sum = <xsl:value-of select="$screens_div_sum"/> ; $system_cache__dita:width_cols.auto.cols=<xsl:value-of select="$system_cache__dita:width_cols.auto.cols"/>; $system_cache__dita:width_cols.auto.div=<xsl:value-of select="$system_cache__dita:width_cols.auto.div"/>; <xsl:value-of select="$system_cache__dita:width_cols.auto"/> </xsl:message>
+        <xsl:value-of select="$system_cache__dita:width_cols.auto"/>
+    </xsl:template><xsl:template match="*|text()|comment()" mode="ditamap_root.embedded_map"/>
+    
+    
+    
+<xsl:template mode="system_cache__dita:xref.topic.result-document" match="@*"><xsl:copy-of select="."/></xsl:template>
+    
+    <xsl:template match="*" mode="system_cache__dita:xref.topic.result-document">
+        <topicref href="{@id}.dita">
+            <xsl:result-document href="{system_cache__dita:xref_result-document(@id)}">
+                <xsl:element name="{name()}">
+                    <xsl:apply-templates select="@*" mode="system_cache__dita:xref.topic.result-document"/>
+                    <!--<xsl:copy-of select="@*"/>-->
+                    <xsl:copy-of select="*"/>
+                </xsl:element>
+            </xsl:result-document>
+        </topicref>
+    </xsl:template>
+    
+    
+    <xsl:template match="simpletable"  mode="table_cut.local_xref">
+        <xsl:param name="header_cols" required="yes"/>
+        <xsl:param name="topic.id" required="yes"/>
+        <xsl:element name="{name()}">
+            <xsl:apply-templates mode="table_cut.local_xref" select="@*"/>
+            <xsl:apply-templates mode="table_cut.local_xref">
+                <xsl:with-param name="header_cols" select="$header_cols"/>
+                <xsl:with-param name="topic.id" select="$topic.id"/>
+            </xsl:apply-templates>
+        </xsl:element>
+    </xsl:template>
+    
+    <xsl:template match="sthead"  mode="table_cut.local_xref">
+        <xsl:copy-of select="."/>
+    </xsl:template>
+    
+    <xsl:template match="strow"  mode="table_cut.local_xref">
+        <xsl:param name="header_cols" required="yes"/>
+        <xsl:param name="topic.id" required="yes"/>
+        <xsl:element name="{name()}">
+            <xsl:copy-of select="@*"/>
+            <xsl:for-each select="stentry [ position() = 1 ]">
+                <xsl:element name="{name()}">
+                    <xsl:copy-of select="@*"/>
+                    <xsl:variable name="position" select="../../@system_cache__dita:position"/>
+                    <!--Pos simpletable="<xsl:value-of select="$position"/>"
+                    next="<xsl:value-of select="../../../simpletable[@system_cache__dita:position &gt; $position]/@system_cache__dita:position"/>"-->
+                    <xsl:variable name="next_id" select="../../../simpletable[ @system_cache__dita:position &gt; $position ][1]/strow/stentry[ position() = 1 and text()= current()]/@id"/>
+                    <xsl:variable name="prev_id" select="../../../simpletable[ @system_cache__dita:position &lt; $position and max(@system_cache__dita:position) ][1]/strow/stentry[ position() = 1 and text()= current()]/@id"/>
+                    
+                    <xsl:if test="$next_id">
+                        <xref href="#{$topic.id}/{$next_id}" format="dita">v</xref>
+                    </xsl:if>
+                    <xsl:if test="$prev_id">
+                        <xref href="#{$topic.id}/{$prev_id}" format="dita">^</xref>
+                    </xsl:if>
+                    <!--<xref href="#{$topic_id}/{$prev_id}" format="dita">^</xref>-->
+                    <xsl:value-of select="text()"/>
+                </xsl:element>
+            </xsl:for-each>
+            <xsl:for-each select="stentry [ position() &gt; 1 ]">
+                <xsl:copy-of select="."/>
+            </xsl:for-each>
+        </xsl:element>
+    </xsl:template>
+    
+    <xsl:function name="system_cache__dita:string.ph.len.max">
+        <xsl:param name="string"/>
+        <xsl:variable name="max_det">
+            <max_det>
+                <xsl:choose>
+                    <xsl:when test="contains($string,' ')">
+                        <xsl:for-each select="tokenize($string,' ')">
+                            <max><xsl:value-of select="string-length(.)"/></max>
+                        </xsl:for-each>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <max><xsl:value-of select="string-length($string)"/></max>
+                    </xsl:otherwise>
+                </xsl:choose>
+            </max_det>
+        </xsl:variable>
+        <xsl:value-of select="max($max_det//max)"/>
+    </xsl:function>
+    
+    <xsl:function name="system_cache__dita:xref_2_topc">
+        <xsl:param name="topic.id"/>
+        <!--<xref href="#topic_ghxf_rum_os_d1e1/simpgletablesss_inaaz_fwf_d1e1_1" format="dita">asd</xref>-->
+        <xref href="{$topic.id}.dita"/>
+    </xsl:function>
+    
+    <xsl:function name="system_cache__dita:xref_2_topc">
+        <xsl:param name="topic.id"/>
+        <xsl:param name="desc"/>
+        <!--<xref href="#topic_ghxf_rum_os_d1e1/simpgletablesss_inaaz_fwf_d1e1_1" format="dita">asd</xref>-->
+        <xref href="{$topic.id}.dita"><xsl:value-of select="$desc"/></xref>
+    </xsl:function>
+    
+    <xsl:function name="system_cache__dita:xref_result-document">
+        <xsl:param name="id"/>
+        <xsl:value-of select="concat($temp,'/',$uuid,'/',$id,'.dita')"/>
+    </xsl:function>
+    
+    <xsl:function name="system_cache__dita:Benford.simpletable.strow.id">
+        <xsl:param name="Benford:year"/>
+        <xsl:param name="Benford:subject"/>
+        <!--<xref href="#topic_ghxf_rum_os_d1e1/simpgletablesss_inaaz_fwf_d1e1_1" format="dita">asd</xref>-->
+        <xsl:value-of select="concat($Benford:subject,'_',$Benford:year)"/>
+    </xsl:function></xsl:stylesheet>

+ 22 - 0
SE/schema/default_db_xml_cache.public/get_all_xsd.xsl

@@ -475,6 +475,25 @@
     <!-- EOF external schema templates -->
     
     
+    <xsl:template name="system_cache__appinfo:get_all_xsd.verify_unique_id">
+        <system_cache__appinfo:get_all_xsd.verify_unique_id>
+            <xsl:variable name="system_cache__appinfo:get_all_xsd" select="doc($procesy5_system_schema)"/>
+            
+        
+        
+            <xsl:for-each select="$system_cache__appinfo:get_all_xsd//schema[ not(@targetNamespace='http://www.w3.org/2001/XMLSchema') and not(@targetNamespace='http://biuro.biall-net.pl/p5/schema/types')]//*[@id and position() &lt; 100] " xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+                <xsl:message>#486 testing <xsl:value-of select="name()"/> and @id=<xsl:value-of select="@id"/></xsl:message>
+                <xsl:choose>
+                    <xsl:when test="count($system_cache__appinfo:get_all_xsd//*[@id = current()/@id]) &gt; 1">
+                        <xsl:message terminate="yes">#489 error duplicate @id for <xsl:value-of select="@id"/> - element <xsl:value-of select="name()"/>/<xsl:value-of select="@name"/>
+                        
+                        </xsl:message>
+                    </xsl:when>
+                </xsl:choose>
+            </xsl:for-each>
+        </system_cache__appinfo:get_all_xsd.verify_unique_id>
+    </xsl:template>
+    
     <xsl:template name="system_cache__appinfo:get_all_xsd">
         <xsl:param name="path2collection" select="$procesy5_system_schema_collection_dir"/> 
         <xsl:param name="get_system_schemas"/>
@@ -494,6 +513,9 @@
                     <xsl:for-each select="$docs">
                         <xsl:message> get_all_xsd przetwarzam plik <xsl:value-of select="document-uri(/)"/></xsl:message>
                         <xsl:choose>
+                            <xsl:when test="contains(document-uri(/),'/ant-object/')">
+                                <xsl:message>#519 ignored /ant-object for <xsl:value-of select="document-uri(/)"/>"/> ;</xsl:message>
+                            </xsl:when>
                             <xsl:when test=" contains(document-uri(/), concat($external_schema,'/'))">
                                 <xsl:comment>#145 Ignored /public_html/external_schema <xsl:value-of select="document-uri(/)"/></xsl:comment>
                                 <system_cache__appinfo:get_all_xsd_external_schema>

+ 19 - 4
SE/schema/default_db_xml_cache.public/main_build_recurse_ant.dita_with_id.xsl

@@ -171,7 +171,9 @@
         <xsl:variable name="build_complexType" select="doc(concat($build_complexType_dir,'/',$prefixed_object_info/system_cache__appinfo:prefixed_object_info/@prefix,'/',$prefixed_object_info/system_cache__appinfo:prefixed_object_info/@element,'.xml'))"/>
         <xsl:variable name="detect_resource_type" select=" system_cache__resources_tree_generate_xsl_required_occurs_raport:detect_resource_type_from_cache(@system_cache__appinfo:ref)"/>
         <xsl:comment>#138 from <xsl:value-of select="@system_cache__appinfo:ref"/>; I get prefixed_object_info/@element <xsl:value-of select="$prefixed_object_info/system_cache__appinfo:prefixed_object_info/@element"/>; </xsl:comment>
-        <xsl:element name="RelatedFeature">
+        <xsl:choose>
+            <xsl:when test="@flat_relation_cache_xpath and @flat_relation_cache_name">
+                <xsl:element name="RelatedFeature">
             <xsl:attribute name="xml_id" select="generate-id()"/>
                  <!-- tymczasowe wymuszenie relacji do obiektu glownego na podstawie $detect_resource_type -->
                  <!-- <xsl:attribute name="typeName" select="p5_tr_map:force_local_typeName(@system_cache__appinfo:ref)"/>-->
@@ -221,7 +223,12 @@
                     </xsl:apply-templates>
                 </xsl:element>
         </xsl:element>
-    </xsl:template>
+        </xsl:when>
+            <xsl:otherwise>
+                <xsl:message>#228 @flat_relation_cache_xpath and @flat_relation_cache_name not set for @id<xsl:value-of select="@id"/></xsl:message>
+                <xsl:comment>#228 @flat_relation_cache_xpath and @flat_relation_cache_name not set for @id<xsl:value-of select="@id"/></xsl:comment>
+            </xsl:otherwise>
+        </xsl:choose></xsl:template>
     
     <xsl:template match="p5_tr_map:go_recurse_from_root_by_build_element_477[@system_cache__appinfo:loop_name]">
         <!--<xsl:param name="build_complexType" required="yes"/>-->
@@ -235,7 +242,9 @@
         <!--<xsl:variable name="build_complexType" select="doc(concat($build_complexType_dir,'/element-',system_cache__appinfo:escape_object_prefix_to_string(@system_cache__appinfo:ref),'.xml'))"/>--><!-- tutaj na podstawie tego powinnismy zbudowac odpowiedni filtr lub olac? o to zadba kolejne wyzwolenie rekursywne-->
         <xsl:variable name="detect_resource_type" select=" system_cache__resources_tree_generate_xsl_required_occurs_raport:detect_resource_type_from_cache(@system_cache__appinfo:ref)"/> 
         <xsl:comment>#190 from <xsl:value-of select="@system_cache__appinfo:ref"/>; I get prefixed_object_info/@element <xsl:value-of select="$prefixed_object_info/system_cache__appinfo:prefixed_object_info/@element"/>; </xsl:comment>
-        <xsl:element name="RelatedFeatureLoop">
+        <xsl:choose>
+            <xsl:when test="@flat_relation_cache_xpath and @flat_relation_cache_name">
+                <xsl:element name="RelatedFeatureLoop">
             <xsl:attribute name="xml_id" select="generate-id()"/>
             <!-- tymczasowe wymuszenie relacji do obiektu glownego na podstawie $detect_resource_type -->
             <!--<xsl:attribute name="typeName" select="p5_tr_map:force_local_typeName(@system_cache__appinfo:ref)"/>-->
@@ -276,7 +285,13 @@
                 <!--<xsl:apply-templates/>-->
             </xsl:element>
         </xsl:element>
-    </xsl:template>
+    </xsl:when>
+            <xsl:otherwise>
+                <xsl:message>#293 @flat_relation_cache_xpath and @flat_relation_cache_name not set for @id<xsl:value-of select="@id"/></xsl:message>
+                <xsl:comment>#293 @flat_relation_cache_xpath and @flat_relation_cache_name not set for @id<xsl:value-of select="@id"/></xsl:comment>
+            </xsl:otherwise>
+        </xsl:choose>
+        </xsl:template>
     
     <xsl:template mode="p5_tr_map:go_recurse_from_root_by_build_element_477_backref" match="*">
         <!-- podmieniamy na relacje od drugiej strony-->

+ 10 - 2
SE/schema/default_db_xml_cache.public/system_cache__appinfo/external_schema_targetNamespace.xsl

@@ -11,6 +11,8 @@
     <xsl:strip-space elements="*"/>
     
     
+    <xsl:param name="default_db_targetNamespace_detect_string" select="'default_db/table/'"/>
+    
     <xsl:function name="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace">
         <xsl:param name="system_cache__appinfo:document-uri"/><!-- system_cache__appinfo:document-uri="external_schema/ksiegi_wieczyste/zsin_1013.xsd" -->
         <xsl:value-of select="replace($system_cache__appinfo:document-uri,'(/|:)','__')"/>
@@ -51,8 +53,14 @@
     
     <xsl:function name="system_cache__appinfo:object_install_se_ant_object.create_targetNamespace_final">
         <xsl:param name="targetNamespace"/> <!-- for use in schema -->
-        <xsl:value-of select="concat($targetNamespace,'.xsd')"/>
-    </xsl:function>
+        <xsl:choose>
+            <xsl:when test="contains($targetNamespace,$default_db_targetNamespace_detect_string)">
+                <xsl:message>#56 TO MOVE TO CONFIG not adding .xsd because of default</xsl:message>
+                <xsl:value-of select="$targetNamespace"/>
+            </xsl:when>
+            <xsl:otherwise><xsl:value-of select="concat($targetNamespace,'.xsd')"/>
+    </xsl:otherwise>
+        </xsl:choose></xsl:function>
     
     <xsl:function name="system_cache__appinfo:object_install_se_ant_object.save_to_ant-object-path">
         <xsl:param name="system_cache__appinfo:document-uri-orig"/> <!-- for use in schema -->