a.binder 8 anni fa
parent
commit
eb7aef876c

+ 20 - 0
SE/schema/WPS_Functions/get_wfs_recurse_xsl/build_get_wfs_recurse_xsl.RelatedFeatureRoot.xsl

@@ -0,0 +1,20 @@
+<?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:bgwrx="http://biuro.biall-net.pl/WPS_Functions/get_wfs_recurse_xsl/get_wfs_recurse_xsl.xsd"
+    exclude-result-prefixes="xs"
+    version="2.0">
+    
+    
+    
+    <xsl:output indent="yes"/>
+    <xsl:strip-space elements="*"/>
+    
+    
+    <xsl:template match="*" mode="bgwrx:RelatedFeatureRoot">
+        <RelatedFeatureRoot>
+            <xsl:copy-of select="."/>
+        </RelatedFeatureRoot>
+    </xsl:template>
+    
+</xsl:stylesheet>

+ 21 - 0
SE/schema/default_db_xml_cache.public/build.system_cache__appinfo.public.PRODUCT.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project basedir="../" 
+    xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
+    name="system_cache__appinfo.public.PRODUCT">
+  
+  
+    <include file="../build.p5build.PRODUCT.xml"/>
+    
+  
+    <property name="system_cache__appinfo.public.PRODUCT.name" value="${p5build_SE.PRODUCT.name}.system_cache__appinfo.public"/>
+    <property name="system_cache__appinfo.public.PRODUCT.vendor-domain" value="${p5build_SE.PRODUCT.vendor-domain}.system_cache__appinfo.public"/>
+    
+    <property name="system_cache__appinfo.public.basedir" location="${basedir}/default_db_xml_cache.public"/>
+    <!--<property name="system_cache__appinfo.build" location="${basedir}/build.xml"/>-->
+    <!--<property name="p5build.temp" location=""/>-->
+    
+   <!-- <property name="system_cache__appinfo.properties" location="${basedir}/.build_properties" />
+    <property name="system_cache__appinfo.properties.xml" location="${basedir}/.build_properties.xml" />--> 
+    
+    
+</project>

+ 265 - 3
SE/schema/default_db_xml_cache.public/build_ant_universal_by_xsl_match.xsl

@@ -6,6 +6,7 @@
     xmlns:system_cache__resources_tree_generate_xsl_required_occurs_raport="http://biuro.biall-net.pl/xmlschema_procesy5/system_cache/resources_tree_generate_xsl_require_occurs_raport"
     xmlns:p5opr="http://biuro.biall-net.pl/xmlschema_procesy5/system_cache/object_parent_relations/object_parent_relations.xsd"
     xmlns:wfs="http://www.opengis.net/wfs"
+    xmlns:p5_simpleSchema_map="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/p5_simpleSchema_map.xsd"
     exclude-result-prefixes="xs"
     version="2.0">
     
@@ -39,7 +40,7 @@
     <!--<xsl:param name="external_schema_table.path" required="yes"/>-->
     
     
-    <xsl:template mode="build_element_complexType.xml build_detect_resource_type.xml build_detect_objects_parent_relations.xml" match="system_cache__appinfo:element_complexType"> <!-- for type generate in main build.xml mode -->
+    <xsl:template mode="build_element_complexType.xml build_detect_resource_type.xml build_detect_objects_parent_relations.xml build_SimpleSchema.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">
                     <xsl:if test="$properties.xml"><xsl:copy-of select="doc($properties.xml)/properties/*" copy-namespaces="no"/></xsl:if>
@@ -59,6 +60,27 @@
                 </project>
     </xsl:template>
     
+    
+    <xsl:template mode="build_object_install_se_ant_object.generate_tables_from_external.get_all_xsd.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">
+            <xsl:if test="$properties.xml"><xsl:copy-of select="doc($properties.xml)/properties/*" copy-namespaces="no"/></xsl:if>
+            <target name="{$antfile_prefix}">
+                <parallel  failonany="true" threadCount="{$threadCount}"> <!-- threadCount="4"  -->
+                    <xsl:variable name="system_cache__appinfo:element_complexType">
+                        <xsl:for-each select="*">
+                            <xsl:sort select="number(@id.int.rand)"/>
+                            <xsl:copy-of select="."/>
+                        </xsl:for-each>
+                    </xsl:variable>
+                    <xsl:apply-templates mode="#current" select="$system_cache__appinfo:element_complexType/*">
+                        <xsl:with-param name="count" select="count(system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external.get_all_xsd)"/>
+                    </xsl:apply-templates>
+                </parallel>                        
+            </target>
+        </project>
+    </xsl:template>
+    
     <xsl:template mode="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,6 +110,10 @@
                 <echo> #54-A suppressed generating <xsl:value-of select="with-param/@name"/> because of  unparsed-text-available(<xsl:value-of select="concat(system_cache__appinfo:element-filename/text(),'.complete')"/>)</echo>
                 <!--<xsl:comment> #54 suppressed generating <xsl:value-of select="with-param/@name"/> because of  unparsed-text-available(<xsl:value-of select="system_cache__appinfo:element-filename/text()"/>)</xsl:comment>-->
             </xsl:when>
+            <!--<xsl:when test="system_cache__appinfo:element-filename/text() and doc-available(system_cache__appinfo:element-filename/text())">
+                <echo> #54-B suppressed generating <xsl:value-of select="with-param/@name"/> because of  unparsed-text-available(<xsl:value-of select="concat(system_cache__appinfo:element-filename/text(),'.complete')"/>)</echo>
+                <!-\-<xsl:comment> #54 suppressed generating <xsl:value-of select="with-param/@name"/> because of  unparsed-text-available(<xsl:value-of select="system_cache__appinfo:element-filename/text()"/>)</xsl:comment>-\->
+            </xsl:when>-->
             <!--disabled all created have .complete - functions checked <xsl:when test="system_cache__appinfo:element-filename/text() and unparsed-text-available(system_cache__appinfo:element-filename/text())">
                 <echo> #54-B suppressed generating <xsl:value-of select="with-param/@name"/> because of  unparsed-text-available(<xsl:value-of select="system_cache__appinfo:element-filename/text()"/>)</echo>
                 <xsl:result-document href="{concat(system_cache__appinfo:element-filename/text(),'.complete')}"><complete/></xsl:result-document>
@@ -97,6 +123,7 @@
                 <sequential>
                     <!--<xsl:attribute name="id.int.rand" select="@id.int.rand"/>-->
                     <!--<tempfile property="{with-param/@select}{with-param/@name}" deleteonexit="yes"><xsl:attribute name="destdir" select="'${detect_resource_type.local}'"/></tempfile>-->
+                    <touch file="{system_cache__appinfo:element-filename/text()}.prepare"/>
                     <echo>creating <xsl:value-of select="round((count( preceding-sibling::*)  div $count ) * 100)"/>%  <xsl:value-of select="with-param/@select"/>:<xsl:value-of select="with-param/@name"/></echo>
                     <xslt     destdir="./"  > <!-- out="${with-param/@select}{with-param/@name}" -->
                         <xsl:attribute name="basedir" select="'${build_complexType.local}'"/>
@@ -156,13 +183,17 @@
                             <xsl:attribute name="name" select="'{http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd}element_complexType.xml'"/>
                             <xsl:attribute name="expression" select="'${element_complexType.xml}'"/>
                         </param>
-                        
+                        <param name="basedir">
+                            <xsl:attribute name="expression" select="'${basedir}'"/>
+                        </param>
                         <classpath location="/opt/local/share/java/saxon9he.jar"/>
                     </xslt>
                     <delete>
                         <xsl:attribute name="file" select="concat('${',with-param/@select,with-param/@name,'}')"/>
                     </delete>
-                    
+                    <delete failonerror="false">
+                        <xsl:attribute name="file" select="concat(system_cache__appinfo:element-filename/text(),'.prepare')"/>
+                    </delete>
                     <xsl:if test="@name='build_element'">
                         <mkdir dir="{system_cache__appinfo:element-filename-prefixed/text()}/../"></mkdir>
                         <symlink  link="{system_cache__appinfo:element-filename-prefixed/text()}" resource="{system_cache__appinfo:element-filename/text()}" overwrite="true"/>
@@ -269,6 +300,9 @@
                             <xsl:attribute name="name" select="'{http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd}element_complexType.xml'"/>
                             <xsl:attribute name="expression" select="'${element_complexType.xml}'"/>
                         </param>
+                        <param name="basedir">
+                            <xsl:attribute name="expression" select="'${basedir}'"/>
+                        </param>
                         <classpath location="/opt/local/share/java/saxon9he.jar"/>
                     </xslt>
                     
@@ -303,6 +337,231 @@
         
     </xsl:template>
     
+    
+    <xsl:template mode="build_SimpleSchema.xml" match="build_cache">
+        <xsl:param name="count"/>
+        <xsl:choose>
+            <xsl:when test="@name='build_element'">
+                <xsl:message>#309 testing against unparsed-text-available <xsl:value-of select="p5_simpleSchema_map:element-filename/text()"/></xsl:message>
+                    <xsl:choose>
+                        <xsl:when test="p5_simpleSchema_map:element-filename/text() and unparsed-text-available(concat(p5_simpleSchema_map:element-filename/text(),'.complete'))">
+                            <echo> #117-A suppressed generating <xsl:value-of select="with-param/@name"/> because of  unparsed-text-available(<xsl:value-of select="concat(p5_simpleSchema_map:element-filename/text(),'.complete')"/>)</echo>
+                            <!--<xsl:comment> #117 suppressed generating <xsl:value-of select="with-param/@name"/> because of  unparsed-text-available(<xsl:value-of select="system_cache__appinfo:element-filename/text()"/>)</xsl:comment>-->
+                        </xsl:when>
+                        <!-- disabled - now all created files has .complete files touched <xsl:when test="p5_tr_map:element-filename/text() and unparsed-text-available(p5_tr_map:element-filename/text())">
+                            <echo> #117-B suppressed generating <xsl:value-of select="with-param/@name"/> because of  unparsed-text-available(<xsl:value-of select="system_cache__appinfo:element-filename/text()"/>)</echo>
+                            <xsl:result-document href="{concat(p5_tr_map:element-filename/text(),'.complete')}"><complete/></xsl:result-document>
+                            <!-\-<xsl:comment> #117 suppressed generating <xsl:value-of select="with-param/@name"/> because of  unparsed-text-available(<xsl:value-of select="system_cache__appinfo:element-filename/text()"/>)</xsl:comment>-\->
+                        </xsl:when>-->
+                        <xsl:otherwise><xsl:comment>#118 not exists <xsl:value-of select="p5_simpleSchema_map:element-filename/text()"/>.complete</xsl:comment>
+                            <sequential>
+                                <!--<tempfile property="{with-param/@select}{with-param/@name}" deleteonexit="yes"><xsl:attribute name="destdir" select="'${detect_resource_type.local}'"/></tempfile>-->
+                                <echo>creating <xsl:value-of select="round((count( preceding-sibling::*)  div $count ) * 100)"/>% <xsl:value-of select="with-param/@select"/>:<xsl:value-of select="with-param/@name"/></echo>
+                                <xslt     destdir="./" force="false"  > <!-- out="${with-param/@select}{with-param/@name}" -->
+                                    <xsl:attribute name="basedir" select="'${p5_tr_map.local}'"/>
+                                    <xsl:attribute name="style" select="'${main_build_recurse_ant.dita_with_id.xsl}'"/>
+                                    <xsl:attribute name="in" select="p5_tr_map:element-filename/text()"/>
+                                    <xsl:attribute name="out" select="p5_simpleSchema_map:element-filename/text()"/> <!-- concat('${',with-param/@select,with-param/@name,'}') -->
+                                    <xsl:choose>
+                                        <xsl:when test="@name='build_element'">
+                                            <factory name="net.sf.saxon.TransformerFactoryImpl">    
+                                                <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
+                                                <!--<attribute name="http://saxon.sf.net/feature/initialMode">
+                                                    <xsl:attribute name="value" select="'{http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/procesy5_translate_map.xsd}go_recurse_from_root_by_build_element.root'"/>
+                                                </attribute>-->
+                                            </factory>
+                                            <!--<param name="parent_type" expression="{with-param/@select}"/>-->
+                                        </xsl:when>
+                                        <!--<xsl:when test="@name='build_complexType'">
+                                            <factory name="net.sf.saxon.TransformerFactoryImpl">    
+                                                <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
+                                                <attribute name="http://saxon.sf.net/feature/initialMode">
+                                                    <xsl:attribute name="value" select="'{http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/procesy5_translate_map.xsd}go_recurse_from_root_by_build_element.root'"/>
+                                                </attribute>
+                                            </factory>
+                                            <param name="parent_type" expression="{with-param/@select}"/>
+                                        </xsl:when>-->
+                                        <xsl:otherwise><xsl:message terminate="yes">#350 unexpected type of element !</xsl:message></xsl:otherwise>
+                                    </xsl:choose>
+                                    <param name="default_db.instance.xml" >
+                                        <xsl:attribute name="expression" select="'${default_db.instance.xml}'"/>
+                                    </param>
+                                    <param name="default_db.instance.xml.symlink">
+                                        <xsl:attribute name="expression" select="'${default_db.instance.xml.symlink}'"/>
+                                    </param>
+                                    <param name="vrtfNamespaces.xml" >
+                                        <xsl:attribute name="expression" select="'${vrtfNamespaces.xml}'"/>
+                                    </param>
+                                    <param name="procesy5_system_schema_file" >
+                                        <xsl:attribute name="expression" select="'${procesy5_system_schema.xml}'"/>
+                                    </param>
+                                    <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}"/>
+                                    <param name="vrtfNamespaces_file">
+                                        <xsl:attribute name="expression" select="'${vrtfNamespaces_file}'"/>
+                                    </param>
+                                    <param name="default_db_targetNamespace_detect_string" expression="{$default_db_targetNamespace_detect_string}"/>
+                                    <param name="zasob_id_db_targetNamespace_detect_string" expression="{$zasob_id_db_targetNamespace_detect_string}"/>
+                                    <param name="NamespaceBinding.xml">
+                                        <xsl:attribute name="expression" select="'${NamespaceBinding.xml}'"/>
+                                    </param>
+                                    <param name="detect_resource_type.local">
+                                        <xsl:attribute name="expression" select="'${detect_resource_type.local}'"/>
+                                    </param>
+                                    <param>
+                                        <xsl:attribute name="name" select="'{http://biuro.biall-net.pl/xmlschema_procesy5/system_cache/object_parent_relations/object_parent_relations.xsd}detect_objects_parent_relations.local'"/>
+                                        <xsl:attribute name="expression" select="'${detect_objects_parent_relations.local}'"/>
+                                    </param>
+                                    <param>
+                                        <xsl:attribute name="name" select="'{http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd}element_complexType.xml'"/>
+                                        <xsl:attribute name="expression" select="'${element_complexType.xml}'"/>
+                                    </param>
+                                    <param name="basedir">
+                                        <xsl:attribute name="expression" select="'${basedir}'"/>
+                                    </param>
+                                    <classpath location="/opt/local/share/java/saxon9he.jar"/>
+                                </xslt>
+                                
+                                <echoxml file="{p5_simpleSchema_map:element-filename/text()}.complete">
+                                    <completed/>
+                                </echoxml>
+                                <!--<touch file="{p5_simpleSchema_map:element-filename/text()}.complete"/>-->
+                                <!--<delete>
+                                    <xsl:attribute name="file" select="concat('${',with-param/@select,with-param/@name,'}')"/>
+                                </delete>-->
+                            </sequential>
+                            <xsl:if test="(($count - count( preceding-sibling::*)) mod 50) = 0">
+                                <sequential>
+                                    <!--<sleep seconds="5"/>-->
+                                    <!--<exec executable="say" spawn="true" failifexecutionfails="false">
+                                        <arg line="-v alex"/>
+                                        <arg line="Generated {round((count( preceding-sibling::*)  div $count ) * 100) } percent of total {$count} objects"/>
+                                    </exec>-->
+                                    <ant  target="p5suis:say_to_queue">
+                                        <xsl:attribute name="antfile" select="'${system_ui_info_speech}'"/>
+                                        <property name="p5suis:say_text" value="Generated {round((count( preceding-sibling::*)  div $count ) * 100) } percent of total {$count} objects" />
+                                    </ant>
+                                    <ant  target="p5suis:say_from_queue">
+                                        <xsl:attribute name="antfile" select="'${system_ui_info_speech}'"/>
+                                    </ant>
+                                </sequential>
+                            </xsl:if>
+                        </xsl:otherwise>
+                    </xsl:choose>
+            </xsl:when>
+        </xsl:choose>
+        
+    </xsl:template>
+    
+    <xsl:template match="build_cache" mode="build_object_install_se_ant_object.generate_tables_from_external.get_all_xsd.xml"/>
+    
+    <xsl:template match="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external.get_all_xsd" mode="build_element_complexType.xml build_detect_resource_type.xml build_detect_objects_parent_relations.xml build_SimpleSchema.xml"/>
+    
+    <xsl:template mode="build_object_install_se_ant_object.generate_tables_from_external.get_all_xsd.xml" match="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external.get_all_xsd">
+        <xsl:param name="count"/>
+        <xsl:message>#434 for @id.int.rand=<xsl:value-of select="@id.int.rand"/>; count(<xsl:value-of select="$count"/>) testing against unparsed-text-available <xsl:value-of select="@system_cache__resources_tree_generate_xsl_required_occurs_raport:element-filename"/></xsl:message>
+        <xsl:choose>
+            <xsl:when test="1=2"/>
+            <xsl:otherwise><!--<xsl:comment>#240 not exists <xsl:value-of select="@system_cache__resources_tree_generate_xsl_required_occurs_raport:element-filename"/></xsl:comment>-->
+                <sequential>
+                    <!--<tempfile property="{with-param/@select}{with-param/@name}" deleteonexit="yes"><xsl:attribute name="destdir" select="'${detect_resource_type.local}'"/></tempfile>-->
+                    <echo>creating <xsl:value-of select="round((count( preceding-sibling::*)  div $count ) * 100)"/>% <xsl:value-of select="with-param/@select"/>:<xsl:value-of select="with-param/@name"/></echo>
+                    <xslt     destdir="./" force="true"  > <!-- out="${with-param/@select}{with-param/@name}" -->
+                        <xsl:attribute name="basedir" select="'${detect_resource_type.local}'"/>
+                        <xsl:attribute name="style" select="'${build_object_install_se_ant_object.xsl}'"/>
+                        <xsl:attribute name="in" select="replace(@system_cache__appinfo:document-uri-full,'file:/','/')"/>
+                        <xsl:attribute name="out" select="concat('${build_object_install_se_ant_object.generate_tables_from_external.xml}.files/',@system_cache__appinfo:document-uri,'.xml')" />
+                        <factory name="net.sf.saxon.TransformerFactoryImpl">    
+                            <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
+                            <attribute name="http://saxon.sf.net/feature/initialMode">
+                                <xsl:attribute name="value" select="'{http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd}object_install_se_ant_object.generate_tables_from_external'"/>
+                            </attribute>
+                        </factory>
+                        <param>
+                            <xsl:attribute name="name" select="'{http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd}document-uri-orig'"/>
+                            <xsl:attribute name="expression" select="@system_cache__appinfo:document-uri-orig"/>
+                        </param>
+                        <param>
+                            <xsl:attribute name="name" select="'{http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd}document-uri'"/>
+                            <xsl:attribute name="expression" select="@system_cache__appinfo:document-uri"/>
+                        </param>
+                        <param name="default_db.instance.xml" >
+                            <xsl:attribute name="expression" select="'${default_db.instance.xml}'"/>
+                        </param>
+                        <param name="default_db.instance.xml.symlink">
+                            <xsl:attribute name="expression" select="'${default_db.instance.xml.symlink}'"/>
+                        </param>
+                        <param name="vrtfNamespaces.xml" >
+                            <xsl:attribute name="expression" select="'${vrtfNamespaces.xml}'"/>
+                        </param>
+                        <param name="procesy5_system_schema_file" >
+                            <xsl:attribute name="expression" select="'${procesy5_system_schema.xml}'"/>
+                        </param>
+                        <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}"/>
+                        <param name="vrtfNamespaces_file">
+                            <xsl:attribute name="expression" select="'${vrtfNamespaces_file}'"/>
+                        </param>
+                        <param name="default_db_targetNamespace_detect_string" expression="{$default_db_targetNamespace_detect_string}"/>
+                        <param name="zasob_id_db_targetNamespace_detect_string" expression="{$zasob_id_db_targetNamespace_detect_string}"/>
+                        <param name="NamespaceBinding.xml">
+                            <xsl:attribute name="expression" select="'${NamespaceBinding.xml}'"/>
+                        </param>
+                        <param name="detect_resource_type.local">
+                            <xsl:attribute name="expression" select="'${detect_resource_type.local}'"/>
+                        </param>
+                        <param>
+                            <xsl:attribute name="name" select="'{http://biuro.biall-net.pl/xmlschema_procesy5/system_cache/object_parent_relations/object_parent_relations.xsd}detect_objects_parent_relations.local'"/>
+                            <xsl:attribute name="expression" select="'${detect_objects_parent_relations.local}'"/>
+                        </param>
+                        <param>
+                            <xsl:attribute name="name" select="'{http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd}element_complexType.xml'"/>
+                            <xsl:attribute name="expression" select="'${element_complexType.xml}'"/>
+                        </param>
+                        <param name="basedir">
+                            <xsl:attribute name="expression" select="'${basedir}'"/>
+                        </param>
+                        <param>
+                            <xsl:attribute name="name" select="'external_schema_table.path'"/>
+                            <xsl:attribute name="expression" select="'${external_schema_table.path}'"/>
+                        </param>
+                        
+                        <classpath location="/opt/local/share/java/saxon9he.jar"/>
+                    </xslt>
+                    <!--<delete>
+                        <xsl:attribute name="file" select="concat('${',with-param/@select,with-param/@name,'}')"/>
+                    </delete>-->
+                    
+                    <touch file="{replace(@system_cache__resources_tree_generate_xsl_required_occurs_raport:element-filename,'file:/','/')}.complete"/>
+                    
+                </sequential>
+                <xsl:if test="(($count - count( preceding-sibling::system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external.get_all_xsd)) mod 50) = 0">
+                    <sequential>
+                        <!--<sleep seconds="5"/>-->
+                        <!--<exec executable="say" spawn="true" failifexecutionfails="false">
+                            <arg line="-v alex"/>
+                            <arg line="Generated {round((count( preceding-sibling::*)  div $count ) * 100) } percent of total {$count} objects"/>
+                        </exec>-->
+                        <ant  target="p5suis:say_to_queue">
+                            <xsl:attribute name="antfile" select="'${system_ui_info_speech}'"/>
+                            <property name="p5suis:say_text" value="Generated {round((count( preceding-sibling::system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external.get_all_xsd)  div $count ) * 100) } percent of total {$count} schemas" />
+                        </ant>
+                        <ant  target="p5suis:say_from_queue">
+                            <xsl:attribute name="antfile" select="'${system_ui_info_speech}'"/>
+                        </ant>
+                        
+                    </sequential>
+                </xsl:if>
+            </xsl:otherwise>
+            
+        </xsl:choose>
+        
+    </xsl:template>
+    
     <xsl:template mode="build_detect_resource_type.xml" match="build_cache">
         <xsl:param name="count"/>
         <xsl:message>#235 for @id.int.rand=<xsl:value-of select="@id.int.rand"/>; count(<xsl:value-of select="$count"/>) testing against unparsed-text-available <xsl:value-of select="@system_cache__resources_tree_generate_xsl_required_occurs_raport:element-filename"/></xsl:message>
@@ -368,6 +627,9 @@
                             <xsl:attribute name="name" select="'{http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd}element_complexType.xml'"/>
                             <xsl:attribute name="expression" select="'${element_complexType.xml}'"/>
                         </param>
+                        <param name="basedir">
+                            <xsl:attribute name="expression" select="'${basedir}'"/>
+                        </param>
                         <classpath location="/opt/local/share/java/saxon9he.jar"/>
                     </xslt>
                     <!--<delete>

+ 233 - 34
SE/schema/default_db_xml_cache.public/build_object_install_se_ant_object.xsl

@@ -4,6 +4,7 @@
     xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
     xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
     xmlns:p5oi="http://biuro.biall-net.pl/WPS_Functions/object_install_se_ant_object/object_install_se_ant_object.xsd"
+    xmlns:xp5r="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache.public/xinclude_p5_recurse/xinclude_p5_recurse.xsd"
     exclude-result-prefixes="xs"
     version="2.0">
     
@@ -21,9 +22,12 @@
     <!--<xsl:param name="external_schema_table.path" required="yes"/>-->
     <!--<xsl:param name="targetNamespace_DEFAULTS_prefix" required="yes"/>-->
     <xsl:param name="disable.save.output"/> <!-- to debugging when errors set to disable output for errors in Cannot write more than one result document to the same UR -->
-    <xsl:param name="system_cache__appinfo:get_all_xsd_default_db.filter.regex" select="'(.*ksiegi_prefi.*)|(.*17666.*)'"/>
-    <xsl:param name="system_cache__appinfo:get_all_xsd.filter.regex" select="'(zzzzxxx.*)|(.*TELBOXES.*)|(.*CRM_PROCESxxx.*)|(.*CRM_IMAGExxxxx.*)|(.*CRM_WSKAZNIKxxx.*)|(.*xxxxxCOMPANIES.*)'"/>
-    <xsl:param name="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix.filter.regex" select="'(.*ksiegi_prefix.*)|(.*17666.*)'"/>
+    <xsl:param name="system_cache__appinfo:get_all_xsd_default_db.filter.regex" select="'(.*wsbpelxxxx.*)|(.*ksiegi_prefi.*)|(.*17666xxxxx.*)'"/>
+    <xsl:param name="system_cache__appinfo:get_all_xsd.filter.regex" select="'(.*wsbpelxxxx.*)|(.*TELBOXESxxxx.*)|(.*CRM_PROCESxxx.*)|(.*CRM_IMAGExxxxx.*)|(.*CRM_WSKAZNIKxxx.*)|(.*xxxxxCOMPANIES.*)'"/>
+    <xsl:param name="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix.filter.regex" select="'(.*wsbpelxxxx.*)|(.*ksiegi_prefix.*)|(.*xxxx17666.*)'"/>
+    
+    <xsl:param name="system_cache__appinfo:document-uri-orig"/>
+    <xsl:param name="system_cache__appinfo:document-uri"/>
     
     <xsl:variable name="NamespaceBinding" select="doc($NamespaceBinding.xml)"/>
     
@@ -49,35 +53,49 @@
         <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="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
+        @targetNamespace='http://www.w3.org/2001/XMLSchema'
+        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" priority="9">
+        <xsl:message>#65 bypassed @targetNamespace <xsl:value-of select="@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[matches(xs:schema/@targetNamespace,$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix.filter.regex)]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external"> <!-- FILTERING [xs:schema/@targetNamespace='https://biuro.biall-net.pl/wfs/default_db/table/ADMIN_USERS.xsd'] -->
         <xsl:message>#53 mached <xsl:value-of select="name()"/></xsl:message>
         <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:with-param name="system_cache__appinfo:document-uri" select="@system_cache__appinfo:document-uri"/>
         </xsl:apply-templates>
     </xsl:template>
     
     <xsl:template match="system_cache__appinfo:get_all_xsd[1=1 and   matches(xs:schema/@targetNamespace,$system_cache__appinfo:get_all_xsd.filter.regex) ]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external"> <!-- FILTERING   matches(xs:schema/@targetNamespace,'(.*CRM_PROCES.*)|(.*CRM_IMAGE.*)|(.*CRM_WSKAZNIK.*)') [xs:schema/@targetNamespace='https://biuro.biall-net.pl/wfs/default_db/table/ADMIN_USERS.xsd'] -->
         <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"/>
+            <xsl:with-param name="system_cache__appinfo:document-uri" select="@system_cache__appinfo:document-uri"/>
         </xsl:apply-templates>
     </xsl:template>
     
     <xsl:template match="system_cache__appinfo:get_all_xsd_default_db[matches(xs:schema/@targetNamespace,$system_cache__appinfo:get_all_xsd_default_db.filter.regex)]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external"> <!-- FILTERING [xs:schema/@targetNamespace='https://biuro.biall-net.pl/wfs/default_db/table/ADMIN_USERS.xsd'] -->
         <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"/>
+            <xsl:with-param name="system_cache__appinfo:document-uri" select="@system_cache__appinfo:document-uri"/>
         </xsl:apply-templates>
     </xsl:template>
     
     <!-- XXXXXX MAIN XXXX MAIN XXXX  XXXXXX MAIN XXXX MAIN XXXX  XXXXXX MAIN XXXX MAIN XXXX -->
     <!-- XXXXXX MAIN XXXX MAIN XXXX  XXXXXX MAIN XXXX MAIN XXXX  XXXXXX MAIN XXXX MAIN XXXX -->
     <xsl:template match="schema" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
-        <xsl:param name="system_cache__appinfo:document-uri-orig" required="yes"/>
+        <xsl:param name="system_cache__appinfo:document-uri-orig" select="$system_cache__appinfo:document-uri-orig"/>
+        <xsl:param name="system_cache__appinfo:document-uri"  select="$system_cache__appinfo:document-uri"/>
         <xsl:variable name="targetNamespace" select="@targetNamespace"/>
-        <xsl:variable name="prefix" select="system_cache__appinfo:prefix_from_targetNamespace($system_cache__appinfo:vrtfNamespaces,@targetNamespace,../@system_cache__appinfo:document-uri)"/>
+        <xsl:variable name="prefix" select="system_cache__appinfo:prefix_from_targetNamespace($system_cache__appinfo:vrtfNamespaces,@targetNamespace,$system_cache__appinfo:document-uri)"/> <!-- ../@system_cache__appinfo:document-uri -->
         <xsl:if test=" string-length($prefix) &lt; 1">
-            <xsl:message terminate="yes">#70 there is problem @targetNamespace=<xsl:value-of select="@targetNamespace"/>; @system_cache__appinfo:document-uri=<xsl:value-of select="../@system_cache__appinfo:document-uri"/> with system_cache__appinfo:vrtfNamespaces - probably need to fix template to match another than  system_cache__appinfo:get_all_xsd_default_db root/child elements</xsl:message>
+            <xsl:message terminate="yes">#70 there is problem @targetNamespace=<xsl:value-of select="@targetNamespace"/>; @system_cache__appinfo:document-uri=<xsl:value-of select="$system_cache__appinfo:document-uri"/> with system_cache__appinfo:vrtfNamespaces - probably need to fix template to match another than  system_cache__appinfo:get_all_xsd_default_db root/child elements</xsl:message>
         </xsl:if>
         <xsl:if test="number($debug_level) &gt; 3"><xsl:message>#82 matched MAIN schema @targetNamespace=<xsl:value-of select="@targetNamespace" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"/></xsl:message></xsl:if>
         <!--<prefix>
@@ -176,7 +194,7 @@
                             <xsl:attribute name="system_cache__appinfo.name" select="@name" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"/>
                             <xsl:attribute name="system_cache__appinfo.targetNamespace" select="$targetNamespace" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"/>
                             <xsl:attribute name="system_cache__appinfo.id" select="@id" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"/>
-                            <xsl:if test="number($debug_level) &gt; 3"><xsl:attribute name="debug.159" select="'test loc'"/></xsl:if>
+                            <xsl:if test="number($debug_level) &gt; 3"><xsl:attribute name="debug.159" select="concat('test loc. @prefix:',@prefix)"/></xsl:if>
                         </xsl:element>
                     </xsl:for-each-group>
                     
@@ -200,7 +218,7 @@
                     
                     <xsl:for-each-group select="current-group()" group-by="concat(@targetNamespace,name(),@name)">
                         <!--<xsl:message>#195 grouped to save schema by name()=<xsl:value-of select="name()"/>; and @name=<xsl:value-of select="@name"/>;</xsl:message>-->
-                        <xsl:comment>#136 grouping schema elements count=<xsl:value-of select="count(current-group())"/></xsl:comment>
+                        <xsl:comment>#136 grouping schema elements count=<xsl:value-of select="count(current-group())"/> for @targetNamespace=<xsl:value-of select="@targetNamespace"/>;</xsl:comment>
                         <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_schema" select=".">
                             <xsl:with-param name="prefix" select="$prefix"/>
                             <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
@@ -232,10 +250,11 @@
                         <xsl:copy-of select="$schema_dirty"/>
                     </debug.231.schema_dirty>
                     
-                     <!--<xsl:comment>#123 saving to <xsl:value-of select="concat($external_schema_table.path,'/',$system_cache__appinfo:document-uri-orig,'/',$schema.prefix,'.xsd')"/> ($schema.prefix = <xsl:value-of select="$schema.prefix"/>); ($system_cache__appinfo:document-uri-orig=<xsl:value-of select="$system_cache__appinfo:document-uri-orig"/>) </xsl:comment>
-                             <xsl:message>#123 saving to  ($schema.prefix = <xsl:value-of select="$schema.prefix"/>); ($system_cache__appinfo:document-uri-orig=<xsl:value-of select="$system_cache__appinfo:document-uri-orig"/>) </xsl:message>-->
-                        <xsl:message>#123A saving to <xsl:value-of select="$schema_save_path"/> by @targetNamespace=<xsl:value-of select="@targetNamespace"/></xsl:message>
-                     <!--<xsl:result-document href="{ concat($external_schema_table.path,'/',$system_cache__appinfo:document-uri-orig,'/',$schema.prefix,'.xsd')}">-->
+                     <!--<xsl:comment>#123 saving to <xsl:value-of select="concat($external_schema_table.path,'/',$system_cache__appinfo:document-uri-orig,'/',$schema.prefix,'.xsd')"/> ($schema.prefix = <xsl:value-of select="$schema.prefix"/>); ($system_cache__appinfo:document-uri-orig=<xsl:value-of select="$system_cache__appinfo:document-uri-orig"/>) </xsl:comment>-->
+                        <!--<xsl:message>#123 saving to  ($schema.prefix = <xsl:value-of select="$schema.prefix"/>); ($system_cache__appinfo:document-uri-orig=<xsl:value-of select="$system_cache__appinfo:document-uri-orig"/>) </xsl:message>-->
+                        <xsl:message>#123A saving to <xsl:value-of select=" substring-after($schema_save_path,'public_html/external_schema_table')"/> by @targetNamespace=<xsl:value-of select="@targetNamespace"/></xsl:message>
+                        <xsl:comment>#123A saving to <xsl:value-of select=" substring-after($schema_save_path,'public_html/external_schema_table')"/> by @targetNamespace=<xsl:value-of select="@targetNamespace"/></xsl:comment>
+                        <!--<xsl:result-document href="{ concat($external_schema_table.path,'/',$system_cache__appinfo:document-uri-orig,'/',$schema.prefix,'.xsd')}">-->
                      
                     <xsl:choose>
                         <xsl:when test="$disable.save.output">
@@ -348,6 +367,7 @@
                 <xsl:element name="{name()}">
                     <xsl:copy-of select="@namespace"/>
                     <xsl:copy-of select="@schemaLocation"/>
+                    <xsl:if test="number($debug_level) &gt; 4"><xsl:attribute name="debug.352">Copied @namespace=<xsl:value-of select="@namespace"/>; @schemaLocation=<xsl:value-of select="@schemaLocation"/> </xsl:attribute></xsl:if>
                 </xsl:element>
             </xsl:otherwise>
         </xsl:choose>
@@ -377,12 +397,32 @@
         </xsl:element>
     </xsl:template>
     
+    <xsl:function name="p5oi:object_root_name">
+        <xsl:param name="prefix"/>
+        <xsl:variable name="translate_object_escaped_prefix_from_string" select="system_cache__appinfo:translate_object_escaped_prefix_from_string($prefix)"/>
+        <xsl:value-of select="tokenize($translate_object_escaped_prefix_from_string,':')[count(tokenize($translate_object_escaped_prefix_from_string,':'))]"/>
+    </xsl:function>
+    
     <xsl:template match="@schemaLocation" mode="system_cache__appinfo:object_install_se_ant_object.ant-object.unique_element.schema.import">
         <xsl:if test="number($debug_level) &gt; 4"><xsl:message>#362 matched  @schemaLocation=<xsl:value-of select="."/>; for params .././@prefix=<xsl:value-of select=".././@prefix"/> ../@system_cache__appinfo.targetNamespace=<xsl:value-of select="../@system_cache__appinfo.targetNamespace"/>; ../@system_cache__appinfo.name=<xsl:value-of select="../@system_cache__appinfo.name"/>; ../@namespace=<xsl:value-of select="../@namespace"/>; </xsl:message></xsl:if>
-        <xsl:variable name="object_root_name" select=" system_cache__appinfo:clean_object_escaped_prefix(.././@prefix)"/>
-        
-        <xsl:attribute name="schemaLocation" select=" concat('../../',replace(system_cache__appinfo:translate_object_escaped_prefix_from_string(.././@prefix),':','.'),'/',$object_root_name,'/',$object_root_name,'.xsd')"/>
-        <xsl:attribute name="system_cache__appinfo:object_install_se_ant_object.save_to_ant-object-path.schemaLocation.reffered" select="system_cache__appinfo:object_install_se_ant_object.save_to_ant-object-path.schemaLocation.reffered(../@system_cache__appinfo.targetNamespace, ../@prefix,../@system_cache__appinfo.name,../@namespace )"/>
+        <xsl:variable name="object_root_name" select="p5oi:object_root_name(.././@prefix)" /> <!-- select=" system_cache__appinfo:clean_object_escaped_prefix_with_db_prefix(.././@prefix)" -->
+        <xsl:message>#384<xsl:copy-of select=".././@*"/></xsl:message>
+        <!--<xsl:choose>
+            <xsl:when test="../@namespace='http://www.w3.org/XML/1998/namespace'">
+                <xsl:attribute name="schemaLocation" select="../@namespace"/>
+            </xsl:when>
+            <xsl:otherwise>-->
+                <xsl:if test="number($debug_level) &gt; 4">
+                    <xsl:attribute name="debug.391" select=" concat('../../',replace(.././@prefix,':','.'),'/',$object_root_name,'/',$object_root_name,'.xsd')"/>
+                    <xsl:attribute name="debug.391.prefix" select=".././@prefix"/>
+                    <xsl:attribute name="debug.391.object_root_name" select="$object_root_name"/>
+                    <xsl:attribute name="debug.391.p5oi.object_root_name" select="p5oi:object_root_name(.././@prefix)"/>
+                </xsl:if>
+                <xsl:attribute name="schemaLocation" select=" concat('../../',replace(system_cache__appinfo:translate_object_escaped_prefix_from_string(.././@prefix),':','.'),'/', system_cache__appinfo:clean_object_prefix($object_root_name),'/',system_cache__appinfo:clean_object_prefix($object_root_name),'.xsd')"/>
+                <xsl:attribute name="system_cache__appinfo:object_install_se_ant_object.save_to_ant-object-path.schemaLocation.reffered" select="system_cache__appinfo:object_install_se_ant_object.save_to_ant-object-path.schemaLocation.reffered(../@system_cache__appinfo.targetNamespace, ../@prefix,../@system_cache__appinfo.name,../@namespace )"/>
+            <!--</xsl:otherwise>
+        </xsl:choose>-->
+      
     </xsl:template>
     
     <xsl:template match="@namespace" mode="system_cache__appinfo:object_install_se_ant_object.ant-object.unique_element.schema.import">
@@ -1002,7 +1042,7 @@
             <xsl:attribute name="prefix" select="$prefix"/>
             <xsl:attribute name="name" select="@name"/>
             <xsl:attribute name="targetNamespace" select="$targetNamespace"/>
-            <xsl:if test="$debug_level &gt; 4"><xsl:attribute name="debug.135">#135BB root element without @type - ...force_refered_complexType (add path) </xsl:attribute></xsl:if>
+            <xsl:if test="$debug_level &gt; 4"><xsl:attribute name="debug.135BB">#135BB root element without @type - ...force_refered_complexType (add path) </xsl:attribute></xsl:if>
             <xsl:comment>#135BB root element without @type - ...force_refered_complexType (add path) </xsl:comment>
             <xsl:element name="{name()}">
                 <xsl:copy-of select="@*"/>
@@ -1044,6 +1084,7 @@
                     <xsl:with-param name="prefix_root" select="$prefix_root"/>
                     <xsl:with-param name="targetNamespace_root" select="$targetNamespace_root"/>
                 </xsl:apply-templates>
+                    <xsl:if test="$debug_level &gt; 4"><xsl:attribute name="debug.135">#135 root element without @type - ...force_refered_complexType (add path) </xsl:attribute></xsl:if>
                 <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType">
                     <xsl:with-param name="name" select="@name"/>
                     <xsl:with-param name="generate_tables_from_external_root.path" select="concat($generate_tables_from_external_root.path,'/',$generate_tables_from_external_root.name)"/>
@@ -1132,6 +1173,48 @@
     
     
     
+    <xsl:template match="element" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root_child.320T" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:param name="generate_tables_from_external_root.name" required="yes"/>
+        <xsl:param name="generate_tables_from_external_root.path" required="yes"/>
+        <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"/>
+        
+        <xsl:variable name="targetNamespace" select="system_cache__appinfo:object_install_se_ant_object.create_targetNamespace($targetNamespace_root,system_cache__appinfo:object_install_se_ant_object.root_complextype( complexType,@name))"/>
+        <xsl:variable name="prefix" select="system_cache__appinfo:object_install_se_ant_object.create_prefix($prefix_root,system_cache__appinfo:object_install_se_ant_object.root_complextype( complexType,@name))"/>
+        
+       <!-- <xsl:variable name="targetNamespace" select="system_cache__appinfo:object_install_se_ant_object.create_targetNamespace($targetNamespace,@name)"/>
+        <xsl:variable name="prefix" select="system_cache__appinfo:object_install_se_ant_object.create_prefix($prefix,@name)"/>-->
+        <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:attribute name="name" select="@name"/>
+            <xsl:if test="number($debug_level) &gt; 4"><xsl:attribute name="debug_344A-320T_root_CT" select="system_cache__appinfo:object_install_se_ant_object.root_complextype( complexType,@name)"/></xsl:if>
+            <xsl:comment>#344A-320T  model:ksiegi_prefix_http/DANE_DZIALKI  TODO  fi create ? root_child element without @type - ...force_refered_complexType (not add path) </xsl:comment>
+            <xsl:element name="{name()}">
+                <xsl:apply-templates select="@*" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root_element_force_type">
+                    <xsl:with-param name="prefix" select="$prefix"/> <!-- system_cache__appinfo:object_install_se_ant_object.create_prefix($prefix,system_cache__appinfo:object_install_se_ant_object.root_complextype( complexType,@name)) -->
+                    <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
+                    <xsl:with-param name="prefix_root" select="$prefix_root"/>
+                    <xsl:with-param name="targetNamespace_root" select="$targetNamespace_root"/>
+                </xsl:apply-templates>
+                <xsl:comment> #344A-320T mode:ksiegi_prefix_http/DANE_DZIALKI - was but not good - suppresed processing - type should be defined in another leaf</xsl:comment>
+                <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType_root.344A">
+                    <xsl:with-param name="name" select="@name"/>
+                    <xsl:with-param name="generate_tables_from_external_root.path" select="concat($generate_tables_from_external_root.path,'/',$generate_tables_from_external_root.name)"/>
+                    <xsl:with-param name="generate_tables_from_external_root.name" select="$generate_tables_from_external_root.name"/>
+                    <xsl:with-param name="prefix" select="$prefix"/>
+                    <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
+                    <xsl:with-param name="prefix_root" select="$prefix_root"/>
+                    <xsl:with-param name="targetNamespace_root" select="$targetNamespace_root"/>
+                </xsl:apply-templates>
+            </xsl:element>
+        </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_child" 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"/>
@@ -1265,7 +1348,8 @@
     </xsl:template>
     <xsl:template match="@type" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root_element_force_type"/>
         
-    
+    <xsl:template match="@minOccurs|@maxOccurs" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root_element_force_type"/>
+        
     <xsl:template match="@name" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root_element_force_type">
         <xsl:param name="targetNamespace" required="yes"/>
         <xsl:param name="prefix" required="yes"/>
@@ -1467,7 +1551,9 @@
         <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:if test="$debug_level &gt; 4"><xsl:attribute name="debug.319">#319 complextype std from child</xsl:attribute></xsl:if>
+            <xsl:attribute name="prefix" select="$prefix"/>
+            <xsl:attribute name="targetNamespace" select="$targetNamespace"/>
+            <xsl:if test="$debug_level &gt; 4"><xsl:attribute name="debug.319">#319 complextype std from child. mod@2018-01-07</xsl:attribute></xsl:if>
             <xsl:comment>#319 complextype std from child</xsl:comment>
             <xsl:element name="{name()}">
                 <xsl:copy-of select="@*"/>
@@ -1610,7 +1696,7 @@
             <xsl:element name="{name()}">
                 <xsl:choose>
                     <xsl:when test="system_cache__appinfo:object_install_se_ant_object.root_complextype( current(),@ref)"><!-- jest ref do czegos co ma CT -->
-                        <xsl:if test="$debug_level &gt; 4"><xsl:attribute name="debug_587_root_complextype" select="system_cache__appinfo:object_install_se_ant_object.root_complextype( current(),@ref)"/></xsl:if>
+                        <xsl:if test="$debug_level &gt; 4"><xsl:attribute name="debug.749AB_root_complextype" select="system_cache__appinfo:object_install_se_ant_object.root_complextype( current(),@ref)"/></xsl:if>
                         <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_ref_to_root" select="@*">
                             <xsl:with-param name="prefix" select="system_cache__appinfo:object_install_se_ant_object.create_prefix($prefix_root, system_cache__appinfo:object_install_se_ant_object.root_complextype(element,@ref))"/>
                             <xsl:with-param name="targetNamespace" select="system_cache__appinfo:object_install_se_ant_object.create_targetNamespace($targetNamespace, system_cache__appinfo:object_install_se_ant_object.root_complextype(element,@ref))"/>
@@ -1625,6 +1711,7 @@
                         </generate_tables_from_external_root.required_by.path_init>
                     </xsl:when>
                     <xsl:otherwise><!-- jest ref tylko do roota -->
+                        <xsl:if test="number($debug_level) &gt; 4"><xsl:attribute name="debug.749AB.else">debug.749AB.else root_complextype=<xsl:value-of select="system_cache__appinfo:object_install_se_ant_object.root_complextype( current(),@ref)"/>  for @ref=<xsl:value-of select="@ref"/></xsl:attribute></xsl:if>
                         <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_ref_to_root" select="@*">
                             <xsl:with-param name="prefix" select="system_cache__appinfo:object_install_se_ant_object.create_prefix($prefix_root, system_cache__appinfo:clean_object_prefix(@ref))"/>
                             <xsl:with-param name="targetNamespace" select="system_cache__appinfo:object_install_se_ant_object.create_targetNamespace($targetNamespace, system_cache__appinfo:clean_object_prefix(@ref))"/>
@@ -1634,9 +1721,9 @@
                         <generate_tables_from_external_root.required_by.path_init>
                             <xsl:attribute name="prefix" select="system_cache__appinfo:object_install_se_ant_object.create_prefix($prefix_root, system_cache__appinfo:clean_object_prefix(@ref))"/>
                             <xsl:attribute name="targetNamespace" select="system_cache__appinfo:object_install_se_ant_object.create_targetNamespace($targetNamespace_root, system_cache__appinfo:clean_object_prefix(@ref))"/>
-                            <xsl:attribute name="debug.749AB">#749AB element[@ref] system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child $default_db_targetNamespace_detect_string=<xsl:value-of select="$default_db_targetNamespace_detect_string"/>; element/@system_cache__appinfo:namespace_uri=<xsl:value-of select="element/@system_cache__appinfo:namespace_uri" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"/>;</xsl:attribute>
+                            <xsl:attribute name="debug.749AB.else">#749AB.else element[@ref] system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child $default_db_targetNamespace_detect_string=<xsl:value-of select="$default_db_targetNamespace_detect_string"/>; element/@system_cache__appinfo:namespace_uri=<xsl:value-of select="element/@system_cache__appinfo:namespace_uri" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"/>;</xsl:attribute>
                             <xsl:attribute name="name" select=" system_cache__appinfo:clean_object_prefix(@ref)"/>
-                            <DEBUG.1258><xsl:copy-of select="." xpath-default-namespace="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"/></DEBUG.1258>
+                            <!--<DEBUG.1258><xsl:copy-of select="." xpath-default-namespace="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"/></DEBUG.1258>-->
                             <DEBUG.1258><xsl:copy-of select="." xpath-default-namespace=""/></DEBUG.1258>
                         </generate_tables_from_external_root.required_by.path_init>
                     </xsl:otherwise>
@@ -1848,7 +1935,7 @@
                 <xsl:attribute name="prefix" select="$prefix"/>
                 <xsl:attribute name="name" select="@name"/>
                 <xsl:comment>#320T complexContent in child - force to make Table with name based on current path (copy element with @ref + make CT) </xsl:comment>
-                <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root_child" select=".">
+                <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root_child.320T" select=".">
                     <xsl:with-param name="generate_tables_from_external_root.path" select="concat($generate_tables_from_external_root.path_new,'/',$generate_tables_from_external_root.name)"/>
                     <xsl:with-param name="generate_tables_from_external_root.name" select="$generate_tables_from_external_root.name"/>
                     <xsl:with-param name="prefix" select="$prefix"/>
@@ -2162,7 +2249,7 @@
         <xsl:attribute name="type" select="concat($prefix,':',system_cache__appinfo:clean_object_prefix(current()))"/>
     </xsl:template>
     
-    <xsl:template match="simpleType[ restriction and restriction[not(@base='xs:anyAtomicType')] and contains(@system_cache__appinfo:namespace_uri,$default_db_targetNamespace_detect_string)]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_type.simpleType" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+    <xsl:template match="simpleType[ not(@name=@id) and restriction and restriction[not(@base='xs:anyAtomicType')] and contains(@system_cache__appinfo:namespace_uri,$default_db_targetNamespace_detect_string)]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_type.simpleType" 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"/>
@@ -2392,6 +2479,7 @@
             <xsl:attribute name="prefix" select="$prefix"/>
             <xsl:attribute name="name" select="@name"/>
             <xsl:attribute name="targetNamespace" select="$targetNamespace"/>
+            <xsl:if test="number($debug_level) &gt; 4"><xsl:attribute name="debug.359A">#359A complexType forced now contintue childs</xsl:attribute></xsl:if>
             <xsl:comment>#359A complexType forced now contintue childs</xsl:comment>
             <xsl:element name="{name()}" >
                 <xsl:copy-of select="@*"/>
@@ -2426,7 +2514,30 @@
         <xsl:copy-of select="."/>
     </xsl:template>
     
-    <xsl:template match="complexType[ sequence and not (@type) ]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType_root" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+    <xsl:template match="*" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType_root.344A">
+        <ERROR_matched.2489>
+            <xsl:attribute name="mode" select="'system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType_root.344A'"/>
+            <xsl:attribute name="name" select="name()"/>
+            <xsl:attribute name="id" select="@id"/>
+            <xsl:attribute name="name.attr" select="@name"/>
+        </ERROR_matched.2489>
+    </xsl:template>
+    <xsl:template match="annotation" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType_root.344A" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:copy-of select="."/>
+    </xsl:template>
+    
+    <xsl:template match="@*" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType_root.344A"/>
+    
+    <xsl:template match="@system_cache__appinfo:sort|@system_cache__appinfo:namespace_uri|@system_cache__appinfo:root_element_in_schema|@system_cache__appinfo:prefix|@system_cache__appinfo:xpath_local" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType_root.344A">
+        <xsl:copy-of select="."/>
+    </xsl:template>
+    
+    <xsl:template match="@id" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType_root.344A">
+        <xsl:param name="random" select="'_CT'"/>
+        <xsl:attribute name="{name()}" select="concat(.,$random)"/>
+    </xsl:template>
+    
+    <xsl:template match="complexType[ sequence and not (@type) ]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType_root.344A" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
         <xsl:param name="name" required="yes"/>
         <xsl:param name="generate_tables_from_external_root.name" select="$name"/>
         <xsl:param name="generate_tables_from_external_root.path" required="yes"/>
@@ -2440,20 +2551,108 @@
             <xsl:attribute name="prefix" select="$prefix"/>
             <xsl:attribute name="targetNamespace" select="$targetNamespace"/>
             <xsl:attribute name="name" select="@name"/>
-            <xsl:comment>#359C complexType forced now contintue childs</xsl:comment>
+            <xsl:comment>#359C-344A complexType forced now contintue childs</xsl:comment>
+            <xs:element name="{@name}" type="{$prefix}:{system_cache__appinfo:object_install_se_ant_object.root_complextype( current(),@name)}"/>
             <xsl:element name="{name()}" >
-                <xsl:copy-of select="@*"/>
+                <!--<xsl:copy-of select="@*"/>-->
+                <xsl:copy-of select="@system_cache__appinfo:root_element_in_schema"/>
+                <xsl:copy-of select="@system_cache__appinfo:prefix"/>
                 <xsl:attribute name="name" select="$name"/>
-                <xsl:if test="number($debug_level) &gt; 3"><xsl:attribute name="debug.939" select="'#939'"/></xsl:if>
-                <xsl:if test="number($debug_level) &gt; 3"><xsl:comment>#359C -  parsing - CT is local leaf</xsl:comment></xsl:if>
-                <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child">
+                <xsl:if test="number($debug_level) &gt; 3"><xsl:attribute name="debug.359C-344A.parent_type" select="'#359C-344A'"/></xsl:if>
+                <xsl:if test="number($debug_level) &gt; 3"><xsl:comment>#359C-344A - this is type like ksiegi_prefix_http/DANE_DZIALKI/DZIALKA - making from this complexContent from parent by system_cache__appinfo:object_install_se_ant_object.root_complextype( current,@name) </xsl:comment></xsl:if>
+                <xs:complexContent>
+                    <xs:extension base="{$prefix}:{system_cache__appinfo:object_install_se_ant_object.root_complextype( current(),@name)}"/>
+                </xs:complexContent>
+                <!--<xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child">
                     <xsl:with-param name="generate_tables_from_external_root.name" select="$generate_tables_from_external_root.name"/>
                     <xsl:with-param name="generate_tables_from_external_root.path" select="concat($generate_tables_from_external_root.path,'/',$generate_tables_from_external_root.name)"/>
                     <xsl:with-param name="prefix" select="$prefix"/>
                     <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
                     <xsl:with-param name="prefix_root" select="$prefix_root"/>
                     <xsl:with-param name="targetNamespace_root" select="$targetNamespace_root"/>
-                </xsl:apply-templates>
+                </xsl:apply-templates>-->
+            </xsl:element>
+        </system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root>
+    </xsl:template>
+    <xsl:function name="p5oi:checkIfDerivatedModelled359C">
+        <xsl:param name="generate_tables_from_external_root.path"/>
+        <xsl:if test="contains($generate_tables_from_external_root.path,'/')"><xsl:value-of select="1"/></xsl:if>
+    </xsl:function>
+    
+    <xsl:template match="complexType[ sequence and not (@type) ]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType_root" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:param name="name" required="yes"/>
+        <xsl:param name="generate_tables_from_external_root.name" select="$name"/>
+        <xsl:param name="generate_tables_from_external_root.path" required="yes"/>
+        <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:attribute name="name" select="@name"/>
+            <xsl:comment>#359C- complexType forced now contintue childs</xsl:comment>
+            <xsl:choose>
+                <xsl:when test="p5oi:checkIfDerivatedModelled359C($generate_tables_from_external_root.path) ">
+                    <xs:element name="{$name}" type="{$prefix}:{$name}">
+                        <xsl:if test="number($debug_level) &gt;4"><xsl:attribute name="debug.359C-1_checkIfDerivatedModelled359C">#359C- p5oi:checkIfDerivatedModelled359C - derivated applied extra element -like=ksiegi_prefix__x3A__DANE_BUDYNKU__x3A__DANE_ADRESOWE:ADRES_BUDYNKU; </xsl:attribute></xsl:if>
+                        <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType_root.344A" select="@*">
+                            <xsl:with-param name="random" select="1"/>
+                        </xsl:apply-templates>
+                    </xs:element>
+                    <xsl:variable name="object_root_name" select="p5oi:object_root_name($prefix)"/>
+                    <xsl:comment>#359C-2 another object_root_name=<xsl:value-of select="$object_root_name"/>; extra complexType and Element of default types - sometimes when modelled are lost in example: ksiegi_prefix__x3A__DANE_BUDYNKU__x3A__DANE_ADRESOWE:ADRES_BUDYNKU </xsl:comment>
+                    <xs:element name="{$object_root_name}" type="{$prefix}:{$object_root_name}">
+                        <xsl:if test="number($debug_level) &gt;4"><xsl:attribute name="debug.359C-2_checkIfDerivatedModelled359C">#359C- p5oi:checkIfDerivatedModelled359C - derivated applied extra element -like=ksiegi_prefix__x3A__DANE_BUDYNKU__x3A__DANE_ADRESOWE:ADRES_BUDYNKU; </xsl:attribute></xsl:if>
+                        <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType_root.344A" select="@*">
+                            <xsl:with-param name="random" select="2"/>
+                        </xsl:apply-templates>
+                    </xs:element>
+                    <!--<xsl:comment>#359C-3 another object_root_name=<xsl:value-of select="$object_root_name"/>; extra complexType</xsl:comment>
+                    <xs:complexType name="{$object_root_name}" >
+                        <xsl:if test="number($debug_level) &gt;4"><xsl:attribute name="debug.359C-3_checkIfDerivatedModelled359C">#359C- p5oi:checkIfDerivatedModelled359C - derivated applied extra element -like=ksiegi_prefix__x3A__DANE_BUDYNKU__x3A__DANE_ADRESOWE:ADRES_BUDYNKU; </xsl:attribute></xsl:if>
+                        <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child_force_refered_complexType_root.344A" select="@*">
+                            <xsl:with-param name="random" select="3"/>
+                        </xsl:apply-templates>
+                        <xs:complexContent>
+                            <xs:extension base="{$prefix}:{$object_root_name}"/>
+                        </xs:complexContent>
+                    </xs:complexType>-->
+                </xsl:when>
+            </xsl:choose>
+            <xsl:element name="{name()}" >
+                <xsl:copy-of select="@*"/>
+                <xsl:attribute name="name" select="$name"/>
+                <xsl:if test="number($debug_level) &gt; 3"><xsl:attribute name="debug.359C" select="'#359C'"/></xsl:if>
+                <xsl:if test="number($debug_level) &gt; 3"><xsl:comment>#359C-exit -  parsing - CT is local leaf</xsl:comment></xsl:if>
+                <xsl:choose>
+                    <xsl:when test="@system_cache__appinfo:extension_base"><!-- todo ? and not(@root-in-schema) -->
+                        <xs:complexContent>
+                            <xs:extension base="{$prefix}:{system_cache__appinfo:clean_object_prefix(@system_cache__appinfo:extension_base)}">
+                                <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child">
+                                    <xsl:with-param name="generate_tables_from_external_root.name" select="$generate_tables_from_external_root.name"/>
+                                    <xsl:with-param name="generate_tables_from_external_root.path" select="concat($generate_tables_from_external_root.path,'/',$generate_tables_from_external_root.name)"/>
+                                    <xsl:with-param name="prefix" select="$prefix"/>
+                                    <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
+                                    <xsl:with-param name="prefix_root" select="$prefix_root"/>
+                                    <xsl:with-param name="targetNamespace_root" select="$targetNamespace_root"/>
+                                </xsl:apply-templates> 
+                            </xs:extension>
+                        </xs:complexContent>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child">
+                            <xsl:with-param name="generate_tables_from_external_root.name" select="$generate_tables_from_external_root.name"/>
+                            <xsl:with-param name="generate_tables_from_external_root.path" select="concat($generate_tables_from_external_root.path,'/',$generate_tables_from_external_root.name)"/>
+                            <xsl:with-param name="prefix" select="$prefix"/>
+                            <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
+                            <xsl:with-param name="prefix_root" select="$prefix_root"/>
+                            <xsl:with-param name="targetNamespace_root" select="$targetNamespace_root"/>
+                        </xsl:apply-templates>
+                    </xsl:otherwise>
+                </xsl:choose>
             </xsl:element>
         </system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root>
     </xsl:template>
@@ -2542,11 +2741,11 @@
         <xsl:copy-of select="."/>
     </xsl:template>
     
-    <xsl:template match="@name" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_mktables.sequence"/>
+    <xsl:template match="@name|@base" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_mktables.sequence"/>
         
     
     
-    <xsl:template match="@type|@targetNamespace|@id|@name|@generate_tables_from_external_root.path.last_token|@generate_tables_from_external_root.name|@generate_tables_from_external_root.path|@prefix|@prefix_root" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_mktables_schema"/>
+    <xsl:template match="@type|@targetNamespace|@id|@name|@generate_tables_from_external_root.path.last_token|@generate_tables_from_external_root.name|@generate_tables_from_external_root.path|@prefix|@prefix_root|@minOccurs|@maxOccurs" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_mktables_schema"/>
         
     
     <xsl:template match="annotation" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_mktables" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">

+ 4 - 4
SE/schema/default_db_xml_cache.public/default_db/dateTime.xsl

@@ -16,20 +16,20 @@
         <xsl:param name="date"/>
         <xsl:choose>
             
-            <xsl:when test="string($data) castable as xs:dateTime">
+            <xsl:when test="string($date) castable as xs:dateTime">
                 <xsl:message>#20 passed as dateTime</xsl:message>
                 <xsl:value-of select="format-date(xs:date(xs:dateTime($data)),'[Y]')"/>
             </xsl:when>
-            <xsl:when test="string($data) castable as xs:date">
+            <xsl:when test="string($date) castable as xs:date">
                 <xsl:message>#20 passed as date</xsl:message>
-                <xsl:value-of select="format-date(xs:date($data),'[Y]')"/>
+                <xsl:value-of select="format-date(xs:date($date),'[Y]')"/>
             </xsl:when>
             <!--<xsl:when test="tokenize(string($date),'\.')[3]">
                 <xsl:message>#20 passed as tokenize</xsl:message>
                 <xsl:value-of select="tokenize($date,'\.')[3]"/>
             </xsl:when>-->
             <xsl:otherwise>
-                <xsl:message terminate="yes">#28 Error in date format for value <xsl:value-of select="$data"/>! </xsl:message>
+                <xsl:message terminate="yes">#28 Error in date format for value <xsl:value-of select="$date"/>! </xsl:message>
             </xsl:otherwise>
             
         </xsl:choose>

+ 32 - 5
SE/schema/default_db_xml_cache.public/get_all_xsd.xsl

@@ -8,12 +8,15 @@
     xmlns:system_cache__resources_tree_generate_xsl_required_occurs_raport="http://biuro.biall-net.pl/xmlschema_procesy5/system_cache/resources_tree_generate_xsl_require_occurs_raport"
     xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
     xmlns:p5opr="http://biuro.biall-net.pl/xmlschema_procesy5/system_cache/object_parent_relations/object_parent_relations.xsd"
+    xmlns:p5_simpleSchema_map="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/p5_simpleSchema_map.xsd"
     xmlns:hfp="http://www.w3.org/2001/XMLSchema-hasFacetAndProperty">
     
+    
+    
     <xsl:import href="system_cache__appinfo/vrtfNamespaces.xsl"/>
     <xsl:import href="p5_tr_map/element-filename.xsl"/>
     <xsl:import href="object_parent_relations/element-filename.xsl"/> <!-- param name="p5opr:detect_objects_parent_relations.local" required="yes"  -->
-    
+    <xsl:include href="p5_simpleSchema_map/element-filename.xsl"/>
     <!--<xsl:import href="system_cache__appinfo/element-filename.xsl"/>-->
     <xsl:output indent="yes"/>
     <xsl:strip-space elements="*"/>
@@ -105,6 +108,7 @@
                 <xsl:variable name="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix">
                     <var>
                         <xsl:for-each select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix/*">
+                            <xsl:message>#111 @name=<xsl:value-of select="@name"/>; name()=<xsl:value-of select="name()"/></xsl:message>
                             <xsl:element name="{name()}">
                                 <xsl:attribute name="pos" select="position()"/>
                                 <xsl:copy-of select="@*"/>
@@ -540,7 +544,9 @@
                 </xsl:variable>
                 <xsl:variable name="docs" select="collection($path)"/>
                 <xsl:variable name="procesy5_system_schema">
-                  <system_cache__appinfo:get_all_xsd_list>
+                  <system_cache__appinfo:get_all_xsd_list
+                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                      xsi:schemaLocation="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd ../../default_db_xml_cache.public/system_cache__appinfo/procesy5_system_schema.xsd">
                     <xsl:for-each select="$docs">
                         <xsl:message> get_all_xsd przetwarzam plik <xsl:value-of select="document-uri(/)"/></xsl:message>
                         <xsl:choose>
@@ -762,6 +768,18 @@
                         <xsl:if test="not(@targetNamespace) or not($prefix_134) ">
                             <xsl:message terminate="yes">#394 ERROR - schema error - set @targetNamespace and prefix for shema file:<xsl:value-of select="../@system_cache__appinfo:document-uri-full"/> ; </xsl:message>
                         </xsl:if>
+                        <xsl:choose>
+                            <xsl:when test="@targetNamespace='http://www.w3.org/2001/XMLSchema'"/>
+                            <xsl:when test="@targetNamespace='http://biuro.biall-net.pl/p5/schema/types'"/>
+                            <xsl:when test="contains(@system_cache__appinfo:document-uri-full,'http://')"/>
+                            <xsl:when test="contains(@system_cache__appinfo:document-uri-full,'https://')"/>
+                            <xsl:otherwise>
+                                <xsl:element name="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external.get_all_xsd">
+                                    <xsl:copy-of select="@*"/>
+                                    <xsl:copy-of select=".././@*"/>
+                                </xsl:element>
+                            </xsl:otherwise>
+                        </xsl:choose>
                         <xsl:if test="count(.//node()[(local-name()='element' or local-name()='complexType' or local-name()='sequence' or local-name()='choice' or local-name()='complexContent' or local-name()='extension' ) and not(@id)])=0">
                                 <xsl:for-each select="(element|complexType)"  xpath-default-namespace="http://www.w3.org/2001/XMLSchema"><!-- dla ograniczenia mozna [$prefix_134='test_objects']-->
                                     <xsl:variable name="complexType_or_element_name186">
@@ -771,8 +789,8 @@
                                             <xsl:otherwise><xsl:message terminate="yes">#391 it should work only for element or complexType</xsl:message></xsl:otherwise>
                                         </xsl:choose>
                                     </xsl:variable>
-                                    <xsl:comment>157: buduje plaski obiekt/mape przetwarzania w celu przeszukania relacji @id:<xsl:value-of select="@id"/>; targetNamespace:<xsl:value-of select="$prefix_134"/>; $complexType_or_element_name186:<xsl:value-of select="$complexType_or_element_name186"/>; name:<xsl:value-of select="@name"/>; namespace-uri-for-prefix:<xsl:value-of select="namespace-uri-for-prefix($prefix_134,.)"/></xsl:comment>
-                                    <xsl:message>157: buduje plaski obiekt/mape przetwarzania w celu przeszukania relacji @id:<xsl:value-of select="@id"/>; targetNamespace:<xsl:value-of select="$prefix_134"/>; $complexType_or_element_name186:<xsl:value-of select="$complexType_or_element_name186"/>; name:<xsl:value-of select="@name"/>; namespace-uri-for-prefix:<xsl:value-of select="namespace-uri-for-prefix($prefix_134,.)"/></xsl:message>
+                                    <xsl:comment>157: buduje plaski obiekt/mape przetwarzania w celu przeszukania relacji @id=<xsl:value-of select="@id"/>; targetNamespace:<xsl:value-of select="$prefix_134"/>; $complexType_or_element_name186=<xsl:value-of select="$complexType_or_element_name186"/>; name:<xsl:value-of select="@name"/>; namespace-uri-for-prefix=<xsl:value-of select="namespace-uri-for-prefix($prefix_134,.)"/></xsl:comment>
+                                    <xsl:message>157: buduje plaski obiekt/mape przetwarzania w celu przeszukania relacji @id=<xsl:value-of select="@id"/>; targetNamespace:<xsl:value-of select="$prefix_134"/>; $complexType_or_element_name186=<xsl:value-of select="$complexType_or_element_name186"/>; name:<xsl:value-of select="@name"/>; namespace-uri-for-prefix=<xsl:value-of select="namespace-uri-for-prefix($prefix_134,.)"/></xsl:message>
                                     <xsl:choose>
                                         <xsl:when test="local-name()='element'">
                                             <build_cache name="build_element">
@@ -792,24 +810,33 @@
                                                 <system_cache__appinfo:targetNamespace><xsl:value-of select="../@targetNamespace"/></system_cache__appinfo:targetNamespace>
                                                 <system_cache__appinfo:name><xsl:value-of select="@name"/></system_cache__appinfo:name>
                                                 <system_cache__appinfo:prefix><xsl:value-of select="$prefix_134"/></system_cache__appinfo:prefix>
-                                                
+                                                <p5_simpleSchema_map:element-filename><xsl:value-of select="p5_simpleSchema_map:element-filename(concat($prefix_134,':',$complexType_or_element_name186),.././@targetNamespace)"/></p5_simpleSchema_map:element-filename>
                                                 <!--<system_cache__resources_tree_generate_xsl_required_occurs_raport:element-filename><xsl:value-of select="system_cache__resources_tree_generate_xsl_required_occurs_raport:element-filename('system_cache__resources_tree_generate_xsl_required_occurs_raport:detect_resource_type.single_element',concat($prefix_134,':',$complexType_or_element_name186))"/></system_cache__resources_tree_generate_xsl_required_occurs_raport:element-filename>-->
                                             </build_cache>
                                         </xsl:when>
                                         <xsl:when test="local-name()='complexType'">
                                             <build_cache name="build_complexType">
                                                 <xsl:attribute name="id.int.rand" select="system_cache__appinfo:id.int.rand(@id)"/>
+                                                <!--<xsl:message>#808.1.DEBUG ok</xsl:message>-->
                                                 <xsl:attribute name="system_cache__appinfo:document-uri" select="../.././@system_cache__appinfo:document-uri"/>
+                                                <!--<xsl:message>#808.2.DEBUG ok</xsl:message>-->
                                                 <xsl:attribute name="system_cache__appinfo:document-uri-full" select="../.././@system_cache__appinfo:document-uri-full"/>
+                                                <!--<xsl:message>#808.3.DEBUG ok</xsl:message>-->
                                                 <xsl:attribute name="system_cache__resources_tree_generate_xsl_required_occurs_raport:element-filename" select="system_cache__resources_tree_generate_xsl_required_occurs_raport:element-filename(../.././@system_cache__appinfo:document-uri, .././@targetNamespace,local-name(),@name)"/>
+                                                <!--<xsl:message>#808.4.DEBUG ok</xsl:message>-->
                                                 <xsl:attribute name="complexType_or_element_name" select="$complexType_or_element_name186"/>
+                                                <!--<xsl:message>#808.5.DEBUG ok</xsl:message>-->
                                                 <xsl:attribute name="p5opr:element-filename" select="p5opr:element-filename(../.././@system_cache__appinfo:document-uri, .././@targetNamespace,local-name(),@name)"/>
+                                                <!--<xsl:message>#808.6.DEBUG ok</xsl:message>-->
                                                 <xsl:attribute name="system_cache__appinfo:path" select="concat(../@targetNamespace,'/',$complexType_or_element_name186)"/>
                                                 <with-param name="complexType"
                                                     select="{$prefix_134}:{$complexType_or_element_name186}"/>
+                                                <!--<xsl:message>#808.7.DEBUG ok</xsl:message>-->
                                                 <system_cache__appinfo:element-filename><xsl:value-of select="system_cache__appinfo:element-filename('build_complexType',@name,$prefix_134,$targetNamespace_134)"/></system_cache__appinfo:element-filename>
                                                 <!--<system_cache__appinfo:element-filename-prefixed><xsl:value-of select="system_cache__appinfo:element-filename-prefixed('build_complexType',@name,$prefix_134,$targetNamespace_134)"/></system_cache__appinfo:element-filename-prefixed>-->
+                                                <!--<xsl:message>#808.8.DEBUG ok</xsl:message>-->
                                                 <p5_tr_map:element-filename><xsl:value-of select="p5_tr_map:element-filename('go_recurse_from_root_by_build_complexType_cache',concat($prefix_134,':',$complexType_or_element_name186))"/></p5_tr_map:element-filename>
+                                                <!--<xsl:message>#808.9.DEBUG ok</xsl:message>-->
                                                 <system_cache__appinfo:targetNamespace><xsl:value-of select="../@targetNamespace"/></system_cache__appinfo:targetNamespace>
                                                 <system_cache__appinfo:name><xsl:value-of select="@name"/></system_cache__appinfo:name>
                                                 <system_cache__appinfo:prefix><xsl:value-of select="$prefix_134"/></system_cache__appinfo:prefix>

+ 406 - 64
SE/schema/default_db_xml_cache.public/get_wfs_recurse_xsl.xsl

@@ -55,9 +55,10 @@
     <xsl:param name="ignore_maxOccurs_0" select="'1'"/>
     
     <xsl:param name="api_recurse"/> <!-- to use api resolveDepth -->
-    <xsl:param name="resolveDepth" select="10"/>
-    <xsl:param name="p5:links.recurse_level.limit" select="5"/>
-    
+    <xsl:param name="resolveDepth" select="5"/>
+    <xsl:param name="p5:links.recurse_level.limit" select="8"/>
+    <xsl:param name="p5:links.next.recurse_level.limit" select="10"/>
+    <xsl:param name="p5:links.loop.context.nodes.min.distance" select="4"/> <!-- when detected in @xlink or @next   <get_wfs_recurse_xsl:context.nodes//@fid , we calculate when it is to be treated as loop, if above $p5:links.recurse_level.limit - to be optimized   -->
     
     
     
@@ -85,7 +86,7 @@
                 <xsl:otherwise><xsl:value-of select="concat($simpleSchema_dir,'/',$targetNamespace_DEFAULTS_prefix,'/',$featureID_name_dita,'.xml')"/></xsl:otherwise>
             </xsl:choose>
         </xsl:variable>
-        <xsl:message>#57 get_wfs_recurse_xsl:GetsimpleSchema: from $typeNameRealResource=<xsl:value-of select="$typeNameRealResource"/>; <xsl:value-of select="$simpleSchemaFile"/></xsl:message>
+        <xsl:message>#57 get_wfs_recurse_xsl:GetsimpleSchema: from $typeNameRealResource=<xsl:value-of select="$typeNameRealResource"/>; <xsl:value-of select="$simpleSchemaFile"/>  for featureID_name_dita=<xsl:value-of select="$featureID_name_dita"/>;</xsl:message>
         
         
         <xsl:if test="not( substring-before(system_cache__appinfo:translate_object_escaped_prefix_from_string(substring-before($typeNameRealResource,':')),':'))">
@@ -156,6 +157,43 @@
     </xsl:template>
     
     
+    
+    
+    <xsl:template match="*" mode="get_wfs_recurse_xsl:context.nodes">
+        <xsl:for-each select=".//*[@fid]">
+            <get_wfs_recurse_xsl:nodes fid="{@fid}" root.distance="{count( ancestor::node())}"/>
+        </xsl:for-each>
+    </xsl:template>
+    
+    
+    <xsl:function name="get_wfs_recurse_xsl:context.PRIMARYKEY.merge">
+        <xsl:param name="get_wfs_recurse_xsl:PRIMARYKEY.nodes"/>
+        <xsl:param name="p5:fid"/>
+        <xsl:choose>
+            <xsl:when test=" string-length($p5:fid) &gt;0">
+                <get_wfs_recurse_xsl:context.nodes>
+                    <xsl:copy-of select="$get_wfs_recurse_xsl:PRIMARYKEY.nodes/get_wfs_recurse_xsl:PRIMARYKEY.nodes/*"/>
+                    <get_wfs_recurse_xsl:nodes fid="{$p5:fid}"/>
+                </get_wfs_recurse_xsl:context.nodes>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:copy-of select="$get_wfs_recurse_xsl:PRIMARYKEY.nodes"/>
+            </xsl:otherwise>
+        </xsl:choose>
+        
+    </xsl:function>
+    
+    
+    <xsl:function name="get_wfs_recurse_xsl:context.nodes.merge">
+        <xsl:param name="get_wfs_recurse_xsl:context.nodes"/>
+        <xsl:param name="current.node"/>
+        <get_wfs_recurse_xsl:context.nodes>
+            <xsl:copy-of select="$get_wfs_recurse_xsl:context.nodes/get_wfs_recurse_xsl:context.nodes/*"/>
+            <xsl:for-each select="$current.node//*[@fid]">
+                <get_wfs_recurse_xsl:nodes fid="{@fid}" root.distance="{count( ancestor::node())}" added="by_merge"/>
+            </xsl:for-each>
+        </get_wfs_recurse_xsl:context.nodes>
+    </xsl:function>
         
     <xsl:function name="get_wfs_recurse_xsl:simpleTypeMakeOgcFilter">
         <xsl:param name="get_wfs_recurse_xsl:GetsimpleSchema"/>
@@ -230,6 +268,66 @@
         <xsl:value-of select="."/>
     </xsl:template>
     
+    <xsl:function name="p5:get_get_from_url">
+        <xsl:param name="p5:url"/> <!-- https://biuro.biall-net.pl/SE/version-git/wfs-data.php?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=GetFeature&amp;TYPENAME=d -->
+        <xsl:param name="get"/><!-- which param from get - maybe REQUEST  -->
+        <xsl:choose>
+            <xsl:when test="contains($p5:url,'?')">
+                <xsl:variable name="result">
+                    <xsl:for-each select="tokenize( substring-after($p5:url,'?'),'&amp;')">
+                        <xsl:if test="substring-before(.,'=') = $get"><xsl:value-of select="substring-after(.,'=')"/></xsl:if>
+                    </xsl:for-each>
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="string-length($result) &gt; 0">
+                        <xsl:value-of select="$result"/>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:message terminate="yes">#263 p5:get_get_from_url - cannot get get value=<xsl:value-of select="$get"/> from url string = <xsl:value-of select="$p5:url"/></xsl:message>
+                    </xsl:otherwise>
+                </xsl:choose>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:message terminate="yes">#268 p5:get_get_from_url url=<xsl:value-of select="$p5:url"/> dont seems correct to extract get</xsl:message>
+            </xsl:otherwise>
+        </xsl:choose>
+        
+    </xsl:function>
+    
+    <xsl:template match="@next" mode="p5:fid">
+        <!-- https://biuro.biall-net.pl/SE/version-git/wfs-data.php?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=GetFeature&amp;TYPENAME=default_db__x3A__BI_audit_MSIG_name%3ABI_audit_MSIG_name&amp;sid=p3s8biqkc8jd4q0ihbqqhr8ueeub7hka9g8nagh3haiqrep37fr6hngspi0m3155v4gl0g2te86dd2hosir0f6l83t7t0j8fsoqq3k2&amp;resolveDepth=4&amp;resolve=all&amp;PRIMARYKEY=7666&amp;SRSNAME=EPSG%3A3003&amp;startIndex=50000&amp;maxFeatures20 -->
+        <xsl:variable name="TYPENAME" select="p5:get_get_from_url(.,'TYPENAME')"/>
+        <xsl:variable name="PRIMARYKEY" select="p5:get_get_from_url(.,'PRIMARYKEY')"/>
+        <xsl:variable name="TYPENAME">
+            <xsl:choose>
+                <xsl:when test="substring-after($TYPENAME,':')">
+                    <xsl:value-of select="substring-after($TYPENAME,':')"/>
+                </xsl:when>
+                <xsl:otherwise>
+                    <xsl:value-of select="$TYPENAME"/>
+                </xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
+        <xsl:value-of select="concat($TYPENAME,'.',$PRIMARYKEY)"/>
+    </xsl:template>
+    
+    <xsl:function  name="p5:fid">
+        <xsl:param name="p5:next"/>
+        <xsl:choose>
+            <xsl:when test="contains($p5:next,'PRIMARYKEY=')">
+                <xsl:variable name="TYPENAME" select="p5:get_get_from_url($p5:next,'TYPENAME')"/>
+                <xsl:variable name="PRIMARYKEY" select="p5:get_get_from_url($p5:next,'PRIMARYKEY')"/>
+                <xsl:value-of select="concat($TYPENAME,'.',$PRIMARYKEY)"/>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:message>#312 cannot retrieve PRIMARYKEY from propably backreffed url=<xsl:value-of select="$p5:next"/></xsl:message>
+            </xsl:otherwise>
+            
+        </xsl:choose>
+        <!-- https://biuro.biall-net.pl/SE/version-git/wfs-data.php?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=GetFeature&amp;TYPENAME=default_db__x3A__BI_audit_MSIG_name%3ABI_audit_MSIG_name&amp;sid=p3s8biqkc8jd4q0ihbqqhr8ueeub7hka9g8nagh3haiqrep37fr6hngspi0m3155v4gl0g2te86dd2hosir0f6l83t7t0j8fsoqq3k2&amp;resolveDepth=4&amp;resolve=all&amp;PRIMARYKEY=7666&amp;SRSNAME=EPSG%3A3003&amp;startIndex=50000&amp;maxFeatures20 -->
+        
+    </xsl:function>
+    
     <xsl:template name="simpleTypeMakeOgcFilter_merge"><!-- do zrobienia polaczonego filtru OGC -->
         <xsl:param name="simpleTypeMakeOgcFilter" required="yes"/>
         <xsl:param name="xpath_dita" required="yes"/> <!-- @value -->
@@ -345,7 +443,12 @@
              </xsl:variable>
              
              <!--<xsl:variable name="url_string" select="concat($protocol,$username,':',$username.pass,'@',$api,'/',$targetNamespace_DEFAULTS_prefix,'/',$request_string)"/>-->
-             <xsl:message>#265 test $php_session_id_ok.string=<xsl:value-of select="$php_session_id_ok.string"/>; $url_string=<xsl:value-of select="$request_string"/> </xsl:message>
+             <xsl:message>#265 test $php_session_id_ok.string=<xsl:value-of select="$php_session_id_ok.string"/>; $url_string=<xsl:value-of select="$request_string"/> 
+                 p5:links.recurse_level.limit = <xsl:value-of select="$p5:links.recurse_level.limit"/>
+                 p5:links.next.recurse_level.limit = <xsl:value-of select="$p5:links.next.recurse_level.limit"/>
+                 resolveDepth = <xsl:value-of select="$resolveDepth"/>
+                 
+             </xsl:message>
              <xsl:variable name="get_wfs_recurse_xsl:wfs_response" select="doc($request_string)"/>
              <xsl:if test="$debug &gt; 5">
                  <wfs_response>
@@ -354,11 +457,28 @@
                      <test>https://a.binder:@biuro.biall-net.pl/SE/version-git/wfs-data.php/default_db/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=GetFeature&amp;TYPENAME=p5_default_db:PROCES_INIT&amp;SRSNAME=EPSG:3003&amp;MAXFEATURES=15</test>
                      
                      <!--<xsl:copy-of select="$wfs_response"/>-->
-                     
                      <xsl:copy-of select="$get_wfs_recurse_xsl:wfs_response"/>
                  </wfs_response>
              </xsl:if>
-             <xsl:choose>
+            <xsl:variable name="get_wfs_recurse_xsl:context.nodes">
+                <get_wfs_recurse_xsl:context.nodes>
+                    <xsl:apply-templates mode="get_wfs_recurse_xsl:context.nodes" select="$get_wfs_recurse_xsl:wfs_response"/>
+                </get_wfs_recurse_xsl:context.nodes>
+            </xsl:variable>
+            <xsl:variable name="get_wfs_recurse_xsl:context.PRIMARYKEY">
+                <get_wfs_recurse_xsl:context.PRIMARYKEY>
+                        <xsl:for-each select="$get_wfs_recurse_xsl:wfs_response/wfs:FeatureCollection/gml:featureMember/*">
+                            <get_wfs_recurse_xsl:nodes>
+                                <xsl:attribute name="fid" select="@fid"/>
+                            </get_wfs_recurse_xsl:nodes>
+                        </xsl:for-each>
+                </get_wfs_recurse_xsl:context.PRIMARYKEY>
+            </xsl:variable>
+            <xsl:if test="number($debug) &gt; 3">
+                 <xsl:copy-of select="$get_wfs_recurse_xsl:context.PRIMARYKEY"/>
+                 <xsl:copy-of select="$get_wfs_recurse_xsl:context.nodes"/>
+            </xsl:if>
+            <xsl:choose>
             <xsl:when test="$api_recurse">
                 <xsl:if test="$get_wfs_recurse_xsl:wfs_response/ServiceExceptionReport" xpath-default-namespace="http://www.opengis.net/ogc">
                     <xsl:message terminate="yes"> Error with query <xsl:value-of select="$get_wfs_recurse_xsl:wfs_response//ServiceException/text()" xpath-default-namespace="http://www.opengis.net/ogc"/></xsl:message>
@@ -370,17 +490,28 @@
                         <xsl:copy-of select="$get_wfs_recurse_xsl:wfs_response/wfs:FeatureCollection/gml:featureMember/namespace::node()"/>
                         <xsl:copy-of select="$get_wfs_recurse_xsl:wfs_response/wfs:FeatureCollection/gml:featureMember/*/namespace::node()"/>
                         <xsl:copy-of select="$get_wfs_recurse_xsl:wfs_response/wfs:FeatureCollection/gml:featureMember//*/namespace::node()"/>-->
-                        <xsl:apply-templates mode="p5:links.evaluate" select="$get_wfs_recurse_xsl:wfs_response/wfs:FeatureCollection/gml:featureMember/*" xpath-default-namespace="http://www.opengis.net/wfs"/>
+                        <xsl:apply-templates mode="p5:links.evaluate" select="$get_wfs_recurse_xsl:wfs_response/wfs:FeatureCollection/gml:featureMember/*" xpath-default-namespace="http://www.opengis.net/wfs">
+                            <xsl:with-param name="get_wfs_recurse_xsl:context.nodes" select="$get_wfs_recurse_xsl:context.nodes"/>
+                            <xsl:with-param name="get_wfs_recurse_xsl:context.PRIMARYKEY" select="$get_wfs_recurse_xsl:context.PRIMARYKEY"/>
+                            <xsl:with-param name="debug.last_wfs_request" select="$request_string"/>
+                        </xsl:apply-templates>
                     </xsl:when>
                     <xsl:otherwise>
                         <xsl:copy-of select="$get_wfs_recurse_xsl:wfs_response/wfs:FeatureCollection/gml:featureMember/*"/>
-                        <xsl:apply-templates mode="p5:links.evaluate" select="$get_wfs_recurse_xsl:wfs_response/wfs:FeatureCollection/gml:featureMember/*" xpath-default-namespace="http://www.opengis.net/wfs"/>
+                        <xsl:apply-templates mode="p5:links.evaluate" select="$get_wfs_recurse_xsl:wfs_response/wfs:FeatureCollection/gml:featureMember/*" xpath-default-namespace="http://www.opengis.net/wfs">
+                            <xsl:with-param name="get_wfs_recurse_xsl:context.nodes" select="$get_wfs_recurse_xsl:context.nodes"/>
+                            <xsl:with-param name="get_wfs_recurse_xsl:context.PRIMARYKEY" select="$get_wfs_recurse_xsl:context.PRIMARYKEY"/>
+                            <xsl:with-param name="debug.last_wfs_request" select="$request_string"/>
+                        </xsl:apply-templates>
                     </xsl:otherwise>
                 </xsl:choose>
             </xsl:when>
             <xsl:otherwise>
                 <xsl:apply-templates mode="after_first_ant_assing_vars" select="$get_wfs_recurse_xsl:GetsimpleSchema">
                     <xsl:with-param name="get_wfs_recurse_xsl:wfs_response" select="$get_wfs_recurse_xsl:wfs_response"/>
+                    <xsl:with-param name="get_wfs_recurse_xsl:context.nodes" select="$get_wfs_recurse_xsl:context.nodes"/>
+                    <xsl:with-param name="get_wfs_recurse_xsl:context.PRIMARYKEY" select="$get_wfs_recurse_xsl:context.PRIMARYKEY"/>
+                    <xsl:with-param name="debug.last_wfs_request" select="$request_string"/>
                 </xsl:apply-templates>
             </xsl:otherwise>
         </xsl:choose>
@@ -390,39 +521,98 @@
     
     <xsl:template match="*[@xlink:href]" mode="p5:links.evaluate"  xpath-default-namespace="http://www.opengis.net/wfs">
         <xsl:param name="p5:links.recurse_level" select="1"/>
+        <xsl:param name="p5:links.next.recurse_level" select="1"/>
+        <xsl:param name="get_wfs_recurse_xsl:context.nodes" required="yes"/>
+        <xsl:param name="get_wfs_recurse_xsl:context.PRIMARYKEY" required="yes"/>
+        <xsl:param name="debug.last_wfs_request" required="yes"/>
+        <xsl:variable name="p5:fid" select="get_wfs_recurse_xsl:REQUEST.fid(@xlink:href)"/>
         <!--<xlink:href.evaluate>-->
-            <xsl:copy>
+           <!-- <xsl:copy>
+                <xsl:copy-of select="@*"/>-->
+        <xsl:if test="number($debug) &gt; 3">
+            <xlink:href.debug509>
+                <xsl:attribute name="debug.last_wfs_request" select="$debug.last_wfs_request"/>
                 <xsl:copy-of select="@*"/>
+            </xlink:href.debug509>
+        </xsl:if>
+                <xsl:message>#516-A  name()<xsl:value-of select="name()"/>; @xlink:href=<xsl:value-of select="@xlink:href"/>;</xsl:message>
+                <xsl:comment>#516-A  name()<xsl:value-of select="name()"/>; @xlink:href=<xsl:value-of select="@xlink:href"/>;</xsl:comment>
                 <xsl:variable name="xlink:request_string">
                     <xsl:apply-templates mode="xlink:request_string" select="."/>
                 </xsl:variable>
-                <xsl:message>#398 p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; at @xlink:href xlink:request_string=<xsl:value-of select="$xlink:request_string"/></xsl:message>
+        <xsl:message>#516-A anchestors.count(<xsl:value-of select="count(ancestor::node())"/>); context.PRIMARYKEY count(<xsl:value-of select="count($get_wfs_recurse_xsl:context.PRIMARYKEY//*[@fid])"/>); previous @fid=count(<xsl:value-of select="count(root()//*[@fid])"/>);  get_wfs_recurse_xsl:context.nodes count(<xsl:value-of select="count($get_wfs_recurse_xsl:context.nodes//*[@fid])"/>); debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:message>
+                <xsl:comment>#516-A anchestors.count(<xsl:value-of select="count(ancestor::node())"/>); context.PRIMARYKEY count(<xsl:value-of select="count($get_wfs_recurse_xsl:context.PRIMARYKEY//*[@fid])"/>); previous @fid=count(<xsl:value-of select="count(root()//*[@fid])"/>);  get_wfs_recurse_xsl:context.nodes count(<xsl:value-of select="count($get_wfs_recurse_xsl:context.nodes//*[@fid])"/>); debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:comment>
+                <!--<xsl:message>#401 previous @fid
+                    <xsl:for-each select="root()//*[@fid]">
+                        <xsl:value-of select="@fid"/>
+                    </xsl:for-each>
+                </xsl:message>-->
                 <xsl:choose>
-                    <xsl:when test="p5:links.recurse_level.limit($p5:links.recurse_level)"/>
+                    <!--<xsl:when test="$get_wfs_recurse_xsl:context.nodes//*[@fid = get_wfs_recurse_xsl:REQUEST.fid( current()/@xlink:href)]">
+                        
+                    </xsl:when>-->
+                    <xsl:when test="root()//*[number(@root.distance) &lt; number($p5:links.loop.context.nodes.min.distance) and @fid = get_wfs_recurse_xsl:REQUEST.fid( current()/@xlink:href)]">
+                        <xsl:message>#398-A match="*[@xlink:href]" - LOOP DETECTED  for <xsl:value-of select="root()//*[@fid = get_wfs_recurse_xsl:REQUEST.fid( current()/@xlink:href)]/concat(@fid,' dist:',@root.distance)"/>  at p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; at p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; BYPASSING  @xlink:href=<xsl:value-of select="@xlink:href"/>; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:message>
+                        <xsl:comment>#398-A match="*[@xlink:href]" - LOOP DETECTED  for <xsl:value-of select="root()//*[@fid = get_wfs_recurse_xsl:REQUEST.fid( current()/@xlink:href)]/concat(@fid,' dist:',@root.distance)"/>  at p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; at p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/> BYPASSING  @xlink:href=<xsl:value-of select="@xlink:href"/>; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:comment>
+                    </xsl:when>
+                    <xsl:when test="p5:links.recurse_level.limit($p5:links.recurse_level)">
+                        <xsl:message>#398-B match="*[@xlink:href]" HIT LIMIT p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; at p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; BYPASSING  @xlink:href=<xsl:value-of select="@xlink:href"/>; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:message>
+                        <xsl:comment>#398-B match="*[@xlink:href]" HIT LIMIT p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; at p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; BYPASSING  @xlink:href=<xsl:value-of select="@xlink:href"/>; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:comment>
+                        <xsl:copy-of select="."/>
+                    </xsl:when>
                     <xsl:when test=" string-length($xlink:request_string) = 0">
-                        <xsl:message>#402 stopped recursion due to ERROR in empty $xlink:request_string - DEBUGGING TODO 2018-01-5</xsl:message>
+                        <xsl:message>#402-C match="*[@xlink:href]" stopped recursion due to ERROR in empty $xlink:request_string - DEBUGGING TODO 2018-01-5; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:message>
+                        <xsl:comment>#402-C match="*[@xlink:href]" stopped recursion due to ERROR in empty $xlink:request_string - DEBUGGING TODO 2018-01-5; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:comment>
                     </xsl:when>
                     <xsl:otherwise>
+                        <xsl:message>#398-D  match="*[@xlink:href]"-B count(.)=<xsl:value-of select="count(.)"/>; continuing still digging at @xlink:href xlink:request_string=<xsl:value-of select="$xlink:request_string"/>; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:message>
+                        <xsl:comment>#398-D  match="*[@xlink:href]"-B count(.)=<xsl:value-of select="count(.)"/>; continuing still digging at @xlink:href xlink:request_string=<xsl:value-of select="$xlink:request_string"/>; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:comment>
+                        
+                        <!--<xsl:variable name="xlink:request_string">
+                            <xsl:apply-templates mode="xlink:request_string" select="."/>
+                        </xsl:variable>-->
                         <xsl:apply-templates select=" get_wfs_recurse_xsl:wfs_response($xlink:request_string)" mode="p5:links.evaluate">
-                            <xsl:with-param name="p5:links.recurse_level" select="$p5:links.recurse_level + 1"/>
+                            <xsl:with-param name="p5:links.recurse_level" select="number($p5:links.recurse_level) + 1"/>
+                            <xsl:with-param name="p5:links.next.recurse_level" select="1"/> <!-- $p5:links.next.recurse_level TODO researching start from beginning -->
+                            <xsl:with-param name="get_wfs_recurse_xsl:context.nodes" select="$get_wfs_recurse_xsl:context.nodes"/>
+                            <xsl:with-param name="get_wfs_recurse_xsl:context.PRIMARYKEY" select="get_wfs_recurse_xsl:context.PRIMARYKEY.merge($get_wfs_recurse_xsl:context.PRIMARYKEY,$p5:fid)"/>
+                            <xsl:with-param name="debug.last_wfs_request" select="$xlink:request_string"/>
                         </xsl:apply-templates>
                     </xsl:otherwise>
                     
                 </xsl:choose>
                 
-            </xsl:copy>
+            <!--</xsl:copy>-->
         <!--</xlink:href.evaluate>-->
     </xsl:template>
     
     
     <xsl:template match="*" mode="p5:links.evaluate"  xpath-default-namespace="http://www.opengis.net/wfs">
         <xsl:param name="p5:links.recurse_level" select="1"/>
-        <xsl:copy>
+        <xsl:param name="p5:links.next.recurse_level" select="1"/>
+        <xsl:param name="get_wfs_recurse_xsl:context.nodes" required="yes"/>
+        <xsl:param name="get_wfs_recurse_xsl:context.PRIMARYKEY" required="yes"/>
+        <xsl:param name="debug.last_wfs_request" required="yes"/>
+       <!-- <xsl:element name="{name()}" inherit-namespaces="yes">
+            <xsl:copy-of select="namespace::node()"/>-->
+        <xsl:copy><!-- debug -->
             <xsl:copy-of select="@*"/>
-            <xsl:apply-templates mode="xlink:href.evaluate" select="@xlink:href"/>
+            <!--<xsl:attribute name="debug.566"> match=* mode=p5:links.evaluate</xsl:attribute>-->
+            <xsl:apply-templates mode="xlink:href.evaluate" select="@xlink:href">
+                <xsl:with-param name="p5:links.recurse_level" select="$p5:links.recurse_level"/>
+                <xsl:with-param name="p5:links.next.recurse_level" select="$p5:links.next.recurse_level"/>
+                <xsl:with-param name="get_wfs_recurse_xsl:context.nodes"  select="$get_wfs_recurse_xsl:context.nodes"/>
+                <xsl:with-param name="get_wfs_recurse_xsl:context.PRIMARYKEY" select="$get_wfs_recurse_xsl:context.PRIMARYKEY"/>
+                <xsl:with-param name="debug.last_wfs_request" select="$debug.last_wfs_request"/>
+            </xsl:apply-templates>
             <xsl:apply-templates mode="p5:links.evaluate">
                 <xsl:with-param name="p5:links.recurse_level" select="$p5:links.recurse_level"/>
+                <xsl:with-param name="p5:links.next.recurse_level" select="$p5:links.next.recurse_level"/>
+                <xsl:with-param name="get_wfs_recurse_xsl:context.nodes"  select="$get_wfs_recurse_xsl:context.nodes"/>
+                <xsl:with-param name="get_wfs_recurse_xsl:context.PRIMARYKEY" select="$get_wfs_recurse_xsl:context.PRIMARYKEY"/>
+                <xsl:with-param name="debug.last_wfs_request" select="$debug.last_wfs_request"/>
             </xsl:apply-templates>
+        <!--</xsl:element>-->
         </xsl:copy>
         <!--<xsl:element name="{name()}" inherit-namespaces="yes"  xpath-default-namespace="http://www.opengis.net/wfs">
             
@@ -434,14 +624,24 @@
     <xsl:function name="p5:links.recurse_level.limit">
         <xsl:param name="p5:links.recurse_level"/>
         <xsl:choose>
-            <xsl:when test="$p5:links.recurse_level &gt; $p5:links.recurse_level.limit">
+            <xsl:when test="number($p5:links.recurse_level) &gt; number($p5:links.recurse_level.limit)">
                 <xsl:value-of select="'limit hit'"/>
-                <xsl:message>#431 $p5:links.recurse_level.limit at <xsl:value-of select="$p5:links.recurse_level"/></xsl:message>
+                <xsl:message>#431-R LIMIT HIT p5:links.recurse_level.limit($p5:links.recurse_level.limit at <xsl:value-of select="$p5:links.recurse_level"/>);</xsl:message>
+                <xsl:comment>#431-R LIMIT HIT p5:links.recurse_level.limit($p5:links.recurse_level.limit at <xsl:value-of select="$p5:links.recurse_level"/>)</xsl:comment>
             </xsl:when>
         </xsl:choose>
-        
     </xsl:function>
     
+    <xsl:function name="p5:links.next.recurse_level.limit">
+        <xsl:param name="p5:links.next.recurse_level"/>
+        <xsl:choose>
+            <xsl:when test="number($p5:links.next.recurse_level.limit) &gt; number($p5:links.next.recurse_level.limit)">
+                <xsl:value-of select="'limit hit'"/>
+                <xsl:message>#431-N LIMIT HIT p5:links.next.recurse_level.limit(<xsl:value-of select="$p5:links.next.recurse_level.limit"/>) at p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>;</xsl:message>
+                <xsl:comment>#431-N LIMIT HIT p5:links.next.recurse_level.limit(<xsl:value-of select="$p5:links.next.recurse_level.limit"/>) at p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>;</xsl:comment>
+            </xsl:when>
+        </xsl:choose>
+    </xsl:function>
     
     <xsl:function name="get_wfs_recurse_xsl:php_session_id_ok.string">
         <xsl:param name="php_session_id_ok.string"/>
@@ -487,7 +687,18 @@
         
         <!--<xsl:value-of select="tokenize($xlink:href,'/')[ 1 to count(tokenize($xlink:href,'.'))]"/>-->
     </xsl:function>
-    
+   
+    <xsl:function name="get_wfs_recurse_xsl:REQUEST.fid">
+        <xsl:param name="xlink:href"/>
+        <xsl:choose>
+            <xsl:when test="substring-after($xlink:href,'#')">
+                <xsl:value-of select=" substring-after($xlink:href,'#')"/>
+            </xsl:when>
+            <xsl:otherwise><xsl:value-of select="false()"/></xsl:otherwise>
+        </xsl:choose>
+
+    </xsl:function>
+   
     <xsl:function name="get_wfs_recurse_xsl:REQUEST.TYPE.PRIMARYKEY">
         <xsl:param name="xlink:href"/>
         
@@ -543,6 +754,7 @@
     
     <xsl:function name="get_wfs_recurse_xsl:wfs_response">
         <xsl:param name="request_string"/>
+        <xsl:message>#741 quering wfs for request_string= <xsl:value-of select="$request_string"/> ;</xsl:message>
         <xsl:variable name="get_wfs_recurse_xsl:wfs_response" select="doc($request_string)"/>
             <xsl:if test="$get_wfs_recurse_xsl:wfs_response/ServiceExceptionReport" xpath-default-namespace="http://www.opengis.net/ogc">
                 <xsl:message terminate="yes"> Error with query <xsl:value-of select="$get_wfs_recurse_xsl:wfs_response//ServiceException/text()" xpath-default-namespace="http://www.opengis.net/ogc"/></xsl:message>
@@ -560,6 +772,10 @@
     
     <xsl:template match="p5:links" mode="p5:links.evaluate">
         <xsl:param name="p5:links.recurse_level" select="1"/>
+        <xsl:param name="p5:links.next.recurse_level" select="1"/>
+        <xsl:param name="get_wfs_recurse_xsl:context.nodes"  required="yes"/>
+        <xsl:param name="get_wfs_recurse_xsl:context.PRIMARYKEY" required="yes"/>
+        <xsl:param name="debug.last_wfs_request" required="yes"/>
         <xsl:variable name="php_session_id_ok.string">
             <xsl:if test=" string-length($php_session_id_ok.string) &gt; 0">
                 <xsl:value-of select="concat('&amp;sid=',normalize-space($php_session_id_ok.string))"/>
@@ -572,12 +788,26 @@
                 </xsl:when>
             </xsl:choose>
         </xsl:variable>
-        <xsl:copy>
-            
+       <!-- <xsl:copy>-->
+            <p5:links><xsl:copy-of select="*"/></p5:links>
             
+            <xsl:variable name="p5:fid" select="p5:fid(p5:next/text())"/>
+            <xsl:message>#684 debug match="p5:links" detected $p5:fid = <xsl:value-of select="$p5:fid"/></xsl:message>
+            <xsl:comment>#684 debug match="p5:links" detected $p5:fid = <xsl:value-of select="$p5:fid"/></xsl:comment>
+            <xsl:copy-of select="$get_wfs_recurse_xsl:context.PRIMARYKEY"/> 
+            <xsl:copy-of select="$get_wfs_recurse_xsl:context.nodes"/>
               <xsl:choose>
-                  <xsl:when test="$p5:links.recurse_level &gt; $p5:links.recurse_level.limit">
-                      <xsl:message>#430 $p5:links.recurse_level.limit at <xsl:value-of select="$p5:links.recurse_level"/></xsl:message>
+                  <xsl:when test="number($p5:links.recurse_level) &gt; number($p5:links.recurse_level.limit)">
+                      <xsl:message>#430 STOPPED digging links by HIT $p5:links.recurse_level.limit at <xsl:value-of select="$p5:links.recurse_level"/>; at p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>;</xsl:message>
+                      <xsl:comment>#430 STOPPED digging links by HIT $p5:links.recurse_level.limit at <xsl:value-of select="$p5:links.recurse_level"/>; at p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>;</xsl:comment>
+                  </xsl:when>
+                  <xsl:when test="$get_wfs_recurse_xsl:context.PRIMARYKEY//*[@fid = $p5:fid]">
+                      <xsl:message> #690 STOPPED match="p5:links" DETECTED PRIMARYKEY FUTURE LOOP BY PRIMARY KEY $p5:fid=<xsl:value-of select="$p5:fid"/>;</xsl:message>
+                      <xsl:comment> #690 STOPPED match="p5:links" DETECTED PRIMARYKEY FUTURE LOOP BY PRIMARY KEY $p5:fid=<xsl:value-of select="$p5:fid"/>;</xsl:comment>
+                  </xsl:when>
+                  <xsl:when test="$get_wfs_recurse_xsl:context.PRIMARYKEY//*[@fid = $p5:fid]">
+                      <xsl:message> #691 STOPPED match="p5:links" DETECTED FUTURE LOOP BY PRIMARY KEY $p5:fid=<xsl:value-of select="$p5:fid"/>;</xsl:message>
+                      <xsl:comment> #691 STOPPED match="p5:links" DETECTED FUTURE LOOP BY PRIMARY KEY $p5:fid=<xsl:value-of select="$p5:fid"/>;</xsl:comment>
                   </xsl:when>
                   <xsl:otherwise>
                       <xsl:variable name="MAXFEATURES.request">
@@ -588,8 +818,8 @@
                       </xsl:variable>
                       
                       <xsl:variable name="request_string" select="concat(p5:next/text(),$php_session_id_ok.string,$api_recurse.request,$MAXFEATURES.request)"/> <!-- ,'&amp;maxFeatures=999' -->
-                      <xsl:message>#415 $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; requesting p5:links <xsl:value-of select="$request_string"/> <xsl:copy-of select="p5:next/@*"></xsl:copy-of></xsl:message>
-                      <xsl:comment>#415 $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; requesting p5:links <xsl:value-of select="$request_string"/></xsl:comment>
+                      <xsl:message>#415 $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>;  p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; requesting p5:links <xsl:value-of select="$request_string"/> <xsl:copy-of select="p5:next/@*"></xsl:copy-of></xsl:message>
+                      <xsl:comment>#415 $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>;  p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; requesting p5:links <xsl:value-of select="$request_string"/></xsl:comment>
                       <!--<request_string>
               <xsl:copy-of select="$request_string"/>
               </request_string>-->
@@ -601,29 +831,41 @@
                       <xsl:choose>
                           <xsl:when test="$get_wfs_recurse_xsl:wfs_response/wfs:FeatureCollection/@next">
                               <!--<debug.438>-->
-                              <xsl:comment>debug.438</xsl:comment>
-                                  <xsl:message> #360-recurse-A to parse to retrieve links and merge xml <xsl:value-of select="$get_wfs_recurse_xsl:wfs_response//p5:next/text()"/></xsl:message>
+                                <xsl:comment>360-recurse-A  $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>;  p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; to parse to retrieve links and merge xml <xsl:value-of select="$get_wfs_recurse_xsl:wfs_response//p5:next/text()"/></xsl:comment>
+                              <xsl:message> #360-recurse-A $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; to parse to retrieve links and merge xml <xsl:value-of select="$get_wfs_recurse_xsl:wfs_response//p5:next/text()"/></xsl:message>
                                   <xsl:apply-templates mode="#current" select="$get_wfs_recurse_xsl:wfs_response">
-                                      <xsl:with-param name="p5:links.recurse_level" select="( $p5:links.recurse_level + 1 )"/>
+                                      <xsl:with-param name="p5:links.recurse_level" select="number($p5:links.recurse_level)"/> <!-- + 1  --><!-- setting to 1 again to research child node -->
+                                      <xsl:with-param name="p5:links.next.recurse_level" select="number($p5:links.next.recurse_level) + 1"/> 
+                                      <xsl:with-param name="get_wfs_recurse_xsl:context.nodes"  select="get_wfs_recurse_xsl:context.nodes.merge($get_wfs_recurse_xsl:context.nodes,$get_wfs_recurse_xsl:wfs_response)"/>
+                                      <xsl:with-param name="get_wfs_recurse_xsl:context.PRIMARYKEY" select="get_wfs_recurse_xsl:context.PRIMARYKEY.merge($get_wfs_recurse_xsl:context.PRIMARYKEY,$p5:fid)"/>
+                                      <xsl:with-param name="debug.last_wfs_request" select="$request_string"/>
                                   </xsl:apply-templates>
                               <!--</debug.438>-->
                           </xsl:when>
                           <xsl:when test="$get_wfs_recurse_xsl:wfs_response//p5:next">
                               <!--<debug.441>-->
-                              <xsl:comment>debug.441</xsl:comment>
-                                  <xsl:message> #360-recurse-B to parse to retrieve links and merge xml <xsl:value-of select="$get_wfs_recurse_xsl:wfs_response//p5:next/text()"/></xsl:message>
+                                    <xsl:comment> #360-recurse-B $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; to parse to retrieve links and merge xml <xsl:value-of select="$get_wfs_recurse_xsl:wfs_response//p5:next/text()"/></xsl:comment>
+                              <xsl:message> #360-recurse-B $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; to parse to retrieve links and merge xml <xsl:value-of select="$get_wfs_recurse_xsl:wfs_response//p5:next/text()"/></xsl:message>
                                   <xsl:apply-templates mode="#current" select="$get_wfs_recurse_xsl:wfs_response">
-                                      <xsl:with-param name="p5:links.recurse_level" select="( $p5:links.recurse_level + 1 )"/>
+                                      <xsl:with-param name="p5:links.recurse_level" select="$p5:links.recurse_level"/> <!-- + 1 ) -->
+                                      <xsl:with-param name="p5:links.next.recurse_level" select=" number($p5:links.next.recurse_level) + 1"/>
+                                      <xsl:with-param name="get_wfs_recurse_xsl:context.nodes" select="get_wfs_recurse_xsl:context.nodes.merge($get_wfs_recurse_xsl:context.nodes,$get_wfs_recurse_xsl:wfs_response)"/>
+                                      <xsl:with-param name="get_wfs_recurse_xsl:context.PRIMARYKEY" select="get_wfs_recurse_xsl:context.PRIMARYKEY.merge($get_wfs_recurse_xsl:context.PRIMARYKEY,$p5:fid)"/>
+                                      <xsl:with-param name="debug.last_wfs_request" select="$request_string"/>
                                   </xsl:apply-templates>
                               <!--</debug.441>-->
                           </xsl:when>
                           <xsl:otherwise>
                               <!--<debug.447>-->
-                              <xsl:comment>debug.447</xsl:comment>
-                                  <xsl:message> #360-recurse-C to parse to retrieve links and merge xml <xsl:value-of select="$get_wfs_recurse_xsl:wfs_response//p5:next/text()"/></xsl:message>
+                                <xsl:comment> #360-recurse-C $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; to parse to retrieve links and merge xml <xsl:value-of select="$get_wfs_recurse_xsl:wfs_response//p5:next/text()"/></xsl:comment>
+                              <xsl:message> #360-recurse-C $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; to parse to retrieve links and merge xml <xsl:value-of select="$get_wfs_recurse_xsl:wfs_response//p5:next/text()"/></xsl:message>
                                   <xsl:copy-of select="$get_wfs_recurse_xsl:wfs_response/wfs:FeatureCollection/@*"/>
                                   <xsl:apply-templates mode="#current" select="$get_wfs_recurse_xsl:wfs_response">
-                                      <xsl:with-param name="p5:links.recurse_level" select="( $p5:links.recurse_level + 1 )"/>
+                                      <xsl:with-param name="p5:links.recurse_level" select="$p5:links.recurse_level"/> <!-- +1 -->
+                                      <xsl:with-param name="p5:links.next.recurse_level" select=" number($p5:links.next.recurse_level) + 1"/>
+                                      <xsl:with-param name="get_wfs_recurse_xsl:context.nodes" select="get_wfs_recurse_xsl:context.nodes.merge($get_wfs_recurse_xsl:context.nodes,$get_wfs_recurse_xsl:wfs_response)"/>
+                                      <xsl:with-param name="get_wfs_recurse_xsl:context.PRIMARYKEY" select="get_wfs_recurse_xsl:context.PRIMARYKEY.merge($get_wfs_recurse_xsl:context.PRIMARYKEY,$p5:fid)"/>
+                                      <xsl:with-param name="debug.last_wfs_request" select="$request_string"/>
                                   </xsl:apply-templates>
                               <!--</debug.447>-->
                           </xsl:otherwise>
@@ -631,7 +873,7 @@
                   </xsl:otherwise>
               </xsl:choose>
             
-        </xsl:copy>
+        <!--</xsl:copy>-->
     </xsl:template>
     
     
@@ -643,7 +885,10 @@
     
     <xsl:template match="wfs:FeatureCollection[@next and gml:featureMember/*]" mode="p5:links.evaluate" >
         <xsl:param name="p5:links.recurse_level" select="1"/>
-        
+        <xsl:param name="p5:links.next.recurse_level" select="1"/>
+        <xsl:param name="get_wfs_recurse_xsl:context.PRIMARYKEY" required="yes"/>
+        <xsl:param name="get_wfs_recurse_xsl:context.nodes" required="yes"/>
+        <xsl:param name="debug.last_wfs_request" required="yes"/>
         
         <xsl:variable name="php_session_id_ok.string">
             <xsl:if test=" string-length($php_session_id_ok.string) &gt; 0">
@@ -653,13 +898,11 @@
         <xsl:variable name="MAXFEATURES.request">
             <xsl:choose>
                 <xsl:when test="contains(@next,'maxFeatures')"/>
-                <xsl:otherwise><xsl:value-of select="concat('&amp;maxFeatures',$MAXFEATURES)"/></xsl:otherwise>
+                <xsl:otherwise><xsl:value-of select="concat('&amp;maxFeatures=',$MAXFEATURES)"/></xsl:otherwise>
             </xsl:choose>
         </xsl:variable>
         <xsl:variable name="request_string" select="concat(@next,$MAXFEATURES.request)"/>
-        
-        
-        
+       
         <!--<xsl:variable name="api_recurse.request">
             <xsl:choose>
                 <xsl:when test="1=1"></xsl:when>
@@ -670,51 +913,105 @@
         </xsl:variable>-->
         
         
+        <xsl:variable name="p5:fid">
+            <xsl:choose>
+                <xsl:when test="contains(@next,'PRIMARYKEY=')">
+                    <xsl:apply-templates select="@next" mode="p5:fid"/>
+                </xsl:when>
+                <xsl:otherwise>
+                    <xsl:message>#833 cannot get PRIMARYKEY from Backreffed - check loop in another leaf from <xsl:value-of select="@next"/></xsl:message>
+                    <xsl:comment>#833 cannot get PRIMARYKEY from Backreffed - check loop in another leaf from <xsl:value-of select="@next"/></xsl:comment>
+                </xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
          <!-- ,'&amp;maxFeatures=999' -->
-        <xsl:message>#511 $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; requesting @next <xsl:value-of select="$request_string"/></xsl:message>
-        <xsl:comment>#511 $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; requesting @next <xsl:value-of select="$request_string"/></xsl:comment>
+        <xsl:message>#511 p5:fid=<xsl:value-of select="$p5:fid"/> $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; requesting @next <xsl:value-of select="$request_string"/>; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:message>
+        <xsl:comment>#511 p5:fid=<xsl:value-of select="$p5:fid"/> $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; requesting @next <xsl:value-of select="$request_string"/>; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:comment>
         <!--<request_string>
         <xsl:copy-of select="$request_string"/>
         </request_string>-->
-        <xsl:variable name="get_wfs_recurse_xsl:wfs_response" select="doc($request_string)"/>
-        <!--<debug.470>-->
-            <!--<xsl:copy-of select="@*"/>-->
-            <!--<debug_current>-->
-                <xsl:comment>debug.current</xsl:comment>
+        <xsl:choose>
+            
+            <xsl:when test="number($p5:links.recurse_level) &gt; $p5:links.recurse_level.limit">
+                <xsl:message>#692-R stopped digging for new p5:fid=<xsl:value-of select="$p5:fid"/> $p5:links.recurse_level.limit at <xsl:value-of select="$p5:links.recurse_level"/>; p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:message>
+                <xsl:comment>#692-R stopped digging for new p5:fid=<xsl:value-of select="$p5:fid"/> $p5:links.recurse_level.limit at <xsl:value-of select="$p5:links.recurse_level"/>; p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:comment>
+            </xsl:when>
+            <xsl:when test="number($p5:links.next.recurse_level) &gt; $p5:links.next.recurse_level.limit">
+                <xsl:message>#692-L stopped digging for new p5:fid=<xsl:value-of select="$p5:fid"/> $p5:links.recurse_level.limit at <xsl:value-of select="$p5:links.recurse_level"/>; p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:message>
+                <xsl:comment>#692-L stopped digging for new p5:fid=<xsl:value-of select="$p5:fid"/> $p5:links.recurse_level.limit at <xsl:value-of select="$p5:links.recurse_level"/>; p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:comment>
+            </xsl:when>
+            <xsl:otherwise>
+                
+                <xsl:comment>debug.current lower; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:comment>
                 <xsl:apply-templates mode="#current">
-                    <xsl:with-param name="p5:links.recurse_level" select="$p5:links.recurse_level + 1"/>
+                    <xsl:with-param name="p5:links.recurse_level" select="number($p5:links.recurse_level) + 1"/>
+                    <xsl:with-param name="p5:links.next.recurse_level" select="$p5:links.next.recurse_level"/>
+                    <xsl:with-param name="get_wfs_recurse_xsl:context.nodes" select="$get_wfs_recurse_xsl:context.nodes"/>
+                    <xsl:with-param name="get_wfs_recurse_xsl:context.PRIMARYKEY" select="get_wfs_recurse_xsl:context.PRIMARYKEY.merge($get_wfs_recurse_xsl:context.PRIMARYKEY,$p5:fid)"/>
+                    <xsl:with-param name="debug.last_wfs_request" select="$debug.last_wfs_request"/>
                 </xsl:apply-templates>
-            <!--</debug_current>-->
-            <!--<debug_reffered>-->
-        <xsl:comment>debug.reffered</xsl:comment>
+                <xsl:comment>debug.current upper / debug.reffered lower; debug.last_wfs_request=<xsl:value-of select="$debug.last_wfs_request"/>;</xsl:comment>
+                
                 <xsl:choose>
-                    <xsl:when test="$get_wfs_recurse_xsl:wfs_response//gml:featureMember/*">
-                        <xsl:apply-templates mode="#current" select="$get_wfs_recurse_xsl:wfs_response">
-                            <xsl:with-param name="p5:links.recurse_level" select="$p5:links.recurse_level + 1"/>
-                        </xsl:apply-templates>
+                    <xsl:when test="$get_wfs_recurse_xsl:context.PRIMARYKEY//*[@fid = $p5:fid]">
+                        <xsl:message>#797 detected FUTURE LOOP  for fid=<xsl:value-of select="$p5:fid"/>  in match="wfs:FeatureCollection[@next </xsl:message>
                     </xsl:when>
                     <xsl:otherwise>
-                        <xsl:message>#498 not any childs</xsl:message>
+                        <xsl:variable name="get_wfs_recurse_xsl:wfs_response" select="doc($request_string)"/>
+                        <xsl:choose> 
+                            <xsl:when test="$get_wfs_recurse_xsl:wfs_response//gml:featureMember/*">
+                                <xsl:apply-templates mode="#current" select="$get_wfs_recurse_xsl:wfs_response">
+                                    <xsl:with-param name="p5:links.recurse_level" select="number($p5:links.recurse_level)"/> <!--  + 1 -->
+                                    <xsl:with-param name="p5:links.next.recurse_level" select="number($p5:links.next.recurse_level) + 1"/>
+                                    <xsl:with-param name="get_wfs_recurse_xsl:context.nodes" select="get_wfs_recurse_xsl:context.nodes.merge($get_wfs_recurse_xsl:context.nodes,$get_wfs_recurse_xsl:wfs_response)"/>
+                                    <xsl:with-param name="get_wfs_recurse_xsl:context.PRIMARYKEY" select="get_wfs_recurse_xsl:context.PRIMARYKEY.merge($get_wfs_recurse_xsl:context.PRIMARYKEY,$p5:fid)"/>
+                                    <xsl:with-param name="debug.last_wfs_request" select="$debug.last_wfs_request"/>
+                                </xsl:apply-templates>
+                            </xsl:when>
+                            <xsl:otherwise>
+                                
+                                <xsl:message>#498 not any childs</xsl:message>
+                            </xsl:otherwise>
+                        </xsl:choose>
                     </xsl:otherwise>
                 </xsl:choose>
                 
-            <!--</debug_reffered>-->
-        <!--</debug.470>-->
+                    
+                <!--</debug_reffered>-->
+                <!--</debug.470>-->
+            </xsl:otherwise>
+        </xsl:choose>
         
     </xsl:template>
     
     <xsl:template match="wfs:FeatureCollection" mode="p5:links.evaluate" >
         <xsl:param name="p5:links.recurse_level" select="1"/>
-        <xsl:message>#538 match wfs:FeatureCollection $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>;</xsl:message>
+        <xsl:param name="p5:links.next.recurse_level" select="1"/>
+        <xsl:param name="get_wfs_recurse_xsl:context.nodes" required="yes"/>
+        <xsl:param name="get_wfs_recurse_xsl:context.PRIMARYKEY" required="yes"/>
+        <xsl:param name="debug.last_wfs_request" required="yes"/>
+        <xsl:message>#538 match wfs:FeatureCollection $p5:links.recurse_level=<xsl:value-of select="$p5:links.recurse_level"/>; p5:links.next.recurse_level=<xsl:value-of select="$p5:links.next.recurse_level"/>;</xsl:message>
         <xsl:apply-templates mode="#current">
-            <xsl:with-param name="p5:links.recurse_level" select="($p5:links.recurse_level + 1)"/>
+            <xsl:with-param name="p5:links.recurse_level" select="(number($p5:links.recurse_level) + 1)"/>
+            <xsl:with-param name="p5:links.next.recurse_level" select="$p5:links.next.recurse_level"/>
+            <xsl:with-param name="get_wfs_recurse_xsl:context.nodes" select="$get_wfs_recurse_xsl:context.nodes"/>
+            <xsl:with-param name="get_wfs_recurse_xsl:context.PRIMARYKEY" select="$get_wfs_recurse_xsl:context.PRIMARYKEY"/>
+            <xsl:with-param name="debug.last_wfs_request" select="$debug.last_wfs_request"/>
         </xsl:apply-templates>
     </xsl:template>
     
     <xsl:template match="gml:featureMember" mode="p5:links.evaluate">
         <xsl:param name="p5:links.recurse_level" select="1"/>
+        <xsl:param name="p5:links.next.recurse_level" select="1"/>
+        <xsl:param name="get_wfs_recurse_xsl:context.nodes" required="yes"/>
+        <xsl:param name="get_wfs_recurse_xsl:context.PRIMARYKEY" required="yes"/>
+        <xsl:param name="debug.last_wfs_request" required="yes"/>
         <xsl:apply-templates mode="#current">
             <xsl:with-param name="p5:links.recurse_level" select="$p5:links.recurse_level"/>
+            <xsl:with-param name="p5:links.next.recurse_level" select="$p5:links.next.recurse_level"/>
+            <xsl:with-param name="get_wfs_recurse_xsl:context.nodes" select="$get_wfs_recurse_xsl:context.nodes"/>
+            <xsl:with-param name="get_wfs_recurse_xsl:context.PRIMARYKEY" select="$get_wfs_recurse_xsl:context.PRIMARYKEY"/>
+            <xsl:with-param name="debug.last_wfs_request" select="$debug.last_wfs_request"/>
         </xsl:apply-templates>
     </xsl:template>
     
@@ -977,7 +1274,8 @@
                     </xsl:choose>
                 </xsl:variable>
                 <!--<xsl:variable name="curr_xpath_tmpl" select="'asdf'"/>-->
-                <xsl:element name="{name()}" >
+                <!--<xsl:element name="{name()}" >-->
+                <xsl:copy>
                     <xsl:attribute name="xpath" select="$curr_xpath_tmpl"/>
                     <xsl:for-each select="@*">
                         <xsl:choose>
@@ -989,7 +1287,8 @@
                     <xsl:apply-templates mode="after_first_ant_assing_xpath">
                         <xsl:with-param name="curr_xpath" select="$curr_xpath_tmpl"/>
                     </xsl:apply-templates>
-                </xsl:element>
+                </xsl:copy>
+                <!--</xsl:element>-->
             </xsl:otherwise>
         </xsl:choose>
     </xsl:template>
@@ -1225,5 +1524,48 @@
     </xsl:template>
     
     
+    <xsl:template match="*" mode="anonimize_for_devel">
+        <xsl:copy>
+            <xsl:copy-of select="@*"/>
+            <xsl:apply-templates mode="#current"/>
+        </xsl:copy>
+    </xsl:template>
+    
+    <xsl:template match="RelatedFeatureRoot" mode="anonimize_for_devel">
+        <wfs:FeatureCollection>
+            <xsl:apply-templates mode="#current"/>
+        </wfs:FeatureCollection>
+    </xsl:template>
+   
+    <xsl:template match="*" mode="anonimize_for_devel">
+        <gml:featureMember>
+            <xsl:apply-templates mode="anonimize_for_devel.child"/>
+        </gml:featureMember>
+    </xsl:template>
+    
+    
+    <xsl:template match="get_wfs_recurse_xsl:context.PRIMARYKEY|get_wfs_recurse_xsl:context.nodes" mode="anonimize_for_devel.child"/>
+    <xsl:template match="text()" mode="anonimize_for_devel.child"/>
+    
+    <xsl:template match="comment()" mode="anonimize_for_devel.child">
+        <xsl:copy-of select="."/>
+    </xsl:template>
+    
+    <xsl:template match="*" mode="anonimize_for_devel.child">
+        <xsl:copy copy-namespaces="no">
+            <xsl:copy-of select="@*"/>
+            <xsl:copy-of select="text()"/>
+            <xsl:apply-templates mode="#current"/>
+        </xsl:copy>
+    </xsl:template>
+    
+    <xsl:template match="*[ local-name()='krs' or local-name()='pesel' or local-name()='nazwa' or local-name()='nazwisko' or local-name()='NIP' or local-name()='REGON' or local-name()='KRS' or local-name()='Pelna_nazwa_kontrahenta' or 
+        local-name()='Ulica' or local-name()='Miejscowosc' or local-name()='Kod_pocztowy' or local-name()='TERYT_SYM_UL' or local-name()='TERYT_SYM'  or local-name()='Numer_budynku']" mode="anonimize_for_devel.child">
+        <xsl:copy copy-namespaces="no">
+            <xsl:copy-of select="@*"/>
+            <xsl:value-of select="concat(substring(text(),1,2),'*****',string-length(text()))"/>
+        </xsl:copy>
+    </xsl:template>
+    
     
 </xsl:stylesheet>

+ 200 - 0
SE/schema/default_db_xml_cache.public/ogc/xs-restriction-pattern.xsl

@@ -0,0 +1,200 @@
+<?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:ogc="http://www.opengis.net/ogc"
+    xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
+    exclude-result-prefixes="xs"
+    version="2.0">
+    
+    <xsl:import href="../escaped_html_to_xml.xsl"/>
+    <xsl:param name="ogc:debug"/>
+    
+    <xsl:variable name="ogc:pattern.debug" select="'((^(?!(BN)|(ND)).+$)|(.+(?&lt;!(BN)|(ND))$))'"/> <!-- ((^(?!(BN)|(ND)).+$)|(.+(?&lt;!(BN)|(ND))$)) -->
+    
+    
+    <xsl:function name="ogc:translate_pattern_to_string">
+        <xsl:param name="ogc:pattern"/> <!-- to convert ? ^ and ! signs to chars -->
+        <xsl:variable name="EXC" select="'!'"/>
+        <xsl:value-of select="  replace(  replace(replace(  replace(   replace(   replace(   replace(replace(replace($ogc:pattern,'&lt;','_LT_'),'\(','&lt;_BRA_&gt;'),'\)','&lt;/_BRA_&gt;') ,'\?','_QM_'  ),'\^','_EXP_'   ),'\$','_DOL_' ),'\+','_PLUS_'), '!','_EXC_' ),'\|','_PIP_' ) "/>
+    </xsl:function>
+    
+    
+    <xsl:template name="ogc:main">
+        <!-- debug -->
+        <ogc:main>
+            <xsl:message>#15 testing for $ogc:pattern=<xsl:value-of select="$ogc:pattern.debug"/>;</xsl:message>
+             
+            <xsl:variable name="ogc:pattern.escaped" select="ogc:translate_pattern_to_string($ogc:pattern.debug)"/>
+            
+             <xsl:variable name="system_cache__appinfo:escaped_html_to_xml" select="system_cache__appinfo:escaped_html_to_xml($ogc:pattern.escaped)"/>
+             
+             <system_cache__appinfo:escaped_html_to_xml>
+                 <xsl:copy-of select="$system_cache__appinfo:escaped_html_to_xml"></xsl:copy-of>
+             </system_cache__appinfo:escaped_html_to_xml>
+             
+            <xsl:apply-templates select="$system_cache__appinfo:escaped_html_to_xml" mode="ogc:translate_pattern_to_string">
+                <xsl:with-param name="name" select="'I_OPER'"/>
+            </xsl:apply-templates>
+            
+        </ogc:main>
+    </xsl:template>
+    
+    
+    <xsl:template mode="ogc:translate_pattern_to_string" match="pattern" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:param name="name" required="yes"/>
+        <xsl:variable name="system_cache__appinfo:escaped_html_to_xml" select="system_cache__appinfo:escaped_html_to_xml(ogc:translate_pattern_to_string(@value))"/>
+        <xsl:if test="number($ogc:debug) &gt; 3"><xsl:message>#45 ogc:translate_pattern_to_string matched pattern count($system_cache__appinfo:escaped_html_to_xml(<xsl:value-of select="count($system_cache__appinfo:escaped_html_to_xml//*)"/>))  at @id=<xsl:value-of select="@id"/>; @value=<xsl:value-of select="@value"/>; </xsl:message></xsl:if>
+        <xsl:apply-templates mode="ogc:translate_pattern_to_string" select="$system_cache__appinfo:escaped_html_to_xml">
+            <xsl:with-param name="name" select="$name"/>
+        </xsl:apply-templates>
+        <!-- to create ogc filter from input like this ((^(?!(BN)|(ND)).+$)|(.+(?&lt;!(BN)|(ND))$)) -->
+        
+        
+    </xsl:template>
+    
+    <xsl:template mode="ogc:translate_pattern_to_string ogc:translate_pattern_to_string.singleNegation" match="text()"/>
+        
+    
+    
+    
+    
+    <xsl:template mode="ogc:translate_pattern_to_string" match="_BRA_[_BRA_ and not(text()='_QM__EXC_') and not( text()='_PIP_')]">
+        <xsl:param name="name" required="yes"/>
+        <xsl:if test="number($ogc:debug) &gt; 3">
+            <xsl:comment>#47 match="_BRA_[_BRA_]" text()=<xsl:value-of select="text()"/>; <xsl:for-each select="./text()">[<xsl:value-of select="position()"/>]=<xsl:value-of select="."/>; </xsl:for-each></xsl:comment>
+            <xsl:message>#47 match="_BRA_[_BRA_]" text()=<xsl:value-of select="text()"/>; <xsl:for-each select="./text()">[<xsl:value-of select="position()"/>]=<xsl:value-of select="."/>; </xsl:for-each></xsl:message>
+        </xsl:if>
+        <xsl:apply-templates mode="ogc:translate_pattern_to_string">
+            <xsl:with-param name="text" select="text()"/>
+            <xsl:with-param name="name" select="$name"/>
+        </xsl:apply-templates>
+    </xsl:template>
+    
+    
+    <xsl:template mode="ogc:translate_pattern_to_string" match="_BRA_[ text()='_PIP_' and  _BRA_/text()='_EXP_'  and  _BRA_/text()='._PLUS__DOL_' and  _BRA_/text()='._PLUS_'  and  _BRA_/text()='_DOL_'  ]" priority="9"> <!--  -->
+        <xsl:param name="name" required="yes"/>
+        <ogc:And> 
+            <xsl:if test="number($ogc:debug) &gt; 3">
+                <xsl:comment>#73-A -
+                    wariant dla pojedynczej negacji aby nie wystepowala wartosc z enum - np I_OPER!= BN or ND
+                    childs _QM__EXC + _QM__LT__EXC - oznacza negacje wystapienia jednego elementu - brac jedno match="_BRA_[_BRA_ and not(text()='_QM__EXC_') and text()='_PIP_']" text()=<xsl:value-of select="text()"/>; <xsl:for-each select="./text()">[<xsl:value-of select="position()"/>]=<xsl:value-of select="."/>; </xsl:for-each></xsl:comment>
+                <xsl:comment> _BRA_/text()=;<xsl:for-each select="_BRA_"> = [<xsl:value-of select="position()"/>]=<xsl:value-of select="text()"/></xsl:for-each></xsl:comment>
+                <xsl:message> _BRA_/text()=;<xsl:for-each select="_BRA_"> = [<xsl:value-of select="position()"/>]=<xsl:value-of select="text()"/></xsl:for-each></xsl:message>
+            </xsl:if>
+            <xsl:apply-templates mode="ogc:translate_pattern_to_string.singleNegation" >
+                <xsl:with-param name="text" select="text()"/>
+                <xsl:with-param name="name" select="$name"/>
+            </xsl:apply-templates>
+        </ogc:And>
+    </xsl:template>
+    
+    <xsl:template mode="ogc:translate_pattern_to_string" match="_BRA_[ text()='._PLUS__DOL_']">
+        <xsl:param name="name" required="yes"/>
+        <xsl:if test="number($ogc:debug) &gt; 3">
+                <xsl:comment>
+                #84-A* Bypased element <xsl:value-of select="name()"/> ; text()=<xsl:value-of select="text()"/></xsl:comment>
+            <xsl:message>
+                #84-A* Bypased element <xsl:value-of select="name()"/> ; text()=<xsl:value-of select="text()"/></xsl:message>
+        </xsl:if>
+        <xsl:apply-templates mode="#current">
+            <xsl:with-param name="name" select="$name"/>
+        </xsl:apply-templates>
+    </xsl:template>
+    
+    
+    <xsl:template mode="ogc:translate_pattern_to_string.singleNegation" match="*">
+        <xsl:param name="name" required="yes"/>
+        <xsl:if test="number($ogc:debug) &gt; 3">
+            <xsl:comment>
+            #84-B* Bypased element <xsl:value-of select="name()"/> ; text()=<xsl:value-of select="text()"/></xsl:comment>
+            <xsl:message>
+            #84-B* Bypased element <xsl:value-of select="name()"/> ; text()=<xsl:value-of select="text()"/></xsl:message>
+        </xsl:if>
+        <xsl:apply-templates mode="#current" select="_BRA_[1]">
+            <xsl:with-param name="name" select="$name"/>
+        </xsl:apply-templates>
+    </xsl:template>
+    
+    <xsl:template mode="ogc:translate_pattern_to_string" match="_BRA_[_BRA_ and not(text()='_QM__EXC_') and text()='_PIP_' and not(text()='_QM__LT__EXC_')]" >
+        <xsl:param name="name" required="yes"/>
+        <ogc:Or>
+            <xsl:if test="number($ogc:debug) &gt; 3">
+                <xsl:comment>#73 match="_BRA_[_BRA_ and not(text()='_QM__EXC_') and text()='_PIP_']"   text()=<xsl:value-of select="text()"/>; <xsl:for-each select="./text()">[<xsl:value-of select="position()"/>]=<xsl:value-of select="."/>; </xsl:for-each></xsl:comment>
+                <xsl:message>#73 match="_BRA_[_BRA_ and not(text()='_QM__EXC_') and text()='_PIP_']"   text()=<xsl:value-of select="text()"/>; <xsl:for-each select="./text()">[<xsl:value-of select="position()"/>]=<xsl:value-of select="."/>; </xsl:for-each></xsl:message>
+                <xsl:comment>
+                   text()=<xsl:value-of select="text()"/>
+                  _BRA_/text()=; <xsl:value-of select="_BRA_/text()"/> <xsl:for-each select="_BRA_/text()"> =  [<xsl:value-of select="position()"/>]=<xsl:value-of select="."/></xsl:for-each></xsl:comment>
+            </xsl:if>
+             <xsl:apply-templates mode="ogc:translate_pattern_to_string">
+                 <xsl:with-param name="text" select="text()"/>
+                 <xsl:with-param name="name" select="$name"/>
+             </xsl:apply-templates>
+        </ogc:Or>
+    </xsl:template>
+    
+    <xsl:template mode="ogc:translate_pattern_to_string" match="_BRA_[_BRA_ and  text()='_QM__EXC_' and text()='_PIP']">
+        <xsl:param name="name" required="yes"/>
+        <ogc:Or>
+            <xsl:comment>#71 match="_BRA_[_BRA_ and text()='_PIP']"</xsl:comment>
+            <xsl:apply-templates mode="ogc:translate_pattern_to_string">
+                <xsl:with-param name="text" select="text()"/>
+                <xsl:with-param name="name" select="$name"/>
+            </xsl:apply-templates>
+        </ogc:Or>
+    </xsl:template>
+    
+    <xsl:template mode="ogc:translate_pattern_to_string" match="_BRA_[ text()='_QM__EXC_' or text()='_QM__LT__EXC_']">
+        <xsl:param name="name" required="yes"/>
+        <xsl:param name="text"/>
+            <ogc:Not>
+                <xsl:if test="number($ogc:debug) &gt; 3"><xsl:comment>#95-A match="_BRA_[ text()='_QM__EXC_' or text()='_QM__LT__EXC_']" - w zasadzie jak jest _QM__LT__EXC_ oraz _QM__EXC_ oznacza to zwykla negacje aby cos nie bylo w tekscie, wiec mozna olac na wstepie dwa dzieci i wziadc jedno
+                        text()=<xsl:value-of select="text()"/>;
+                        </xsl:comment>
+                </xsl:if>
+                <!--<parent_text><xsl:value-of select="$text"/>  <xsl:for-each select="$text">[<xsl:value-of select="position()"/>]=<xsl:value-of select="."/>; </xsl:for-each></parent_text>-->
+                <!--<current><xsl:copy-of select="*"></xsl:copy-of></current>-->
+                <xsl:apply-templates mode="#current">
+                    <xsl:with-param name="text" select="text()"/>
+                    <xsl:with-param name="name" select="$name"/>
+                </xsl:apply-templates>
+            </ogc:Not>
+    </xsl:template>
+    
+    <xsl:template mode="ogc:translate_pattern_to_string.singleNegation" match="_BRA_[  text()='_QM__EXC_']">
+        <xsl:message>#144 bypassed for once filter</xsl:message>
+    </xsl:template>
+    <xsl:template mode="ogc:translate_pattern_to_string.singleNegation" match="_BRA_[  text()='_QM__LT__EXC_']">
+        <xsl:param name="name" required="yes"/>
+        <xsl:param name="text"/>
+        <ogc:Not>
+            <xsl:if test="number($ogc:debug) &gt; 3">
+                <xsl:comment>#95-B match="_BRA_[ text()='_QM__EXC_' or text()='_QM__LT__EXC_']" - w zasadzie jak jest _QM__LT__EXC_ oraz _QM__EXC_ oznacza to zwykla negacje aby cos nie bylo w tekscie, wiec mozna olac na wstepie dwa dzieci i wziadc jedno
+                          text()=<xsl:value-of select="text()"/>;
+                </xsl:comment>
+            </xsl:if>
+            <!--<parent_text><xsl:value-of select="$text"/>  <xsl:for-each select="$text">[<xsl:value-of select="position()"/>]=<xsl:value-of select="."/>; </xsl:for-each></parent_text>-->
+            <!--<current><xsl:copy-of select="*"></xsl:copy-of></current>-->
+            <xsl:apply-templates mode="#current">
+                <xsl:with-param name="text" select="text()"/>
+                <xsl:with-param name="name" select="$name"/>
+            </xsl:apply-templates>
+        </ogc:Not>
+    </xsl:template>
+    
+    
+    <xsl:template mode="ogc:translate_pattern_to_string ogc:translate_pattern_to_string.singleNegation" match="_BRA_[not(_BRA_) and text()]">
+        <xsl:param name="name" required="yes"/>
+        <ogc:PropertyIsEqualTo>
+            <xsl:if test="number($ogc:debug) &gt; 3">
+                <xsl:comment>
+                    #137 matched text()=<xsl:value-of select="text()"/>;
+                </xsl:comment>
+            </xsl:if>
+            <ogc:PropertyName><xsl:value-of select="$name"/></ogc:PropertyName>
+            <ogc:Literal><xsl:value-of select="text()"/></ogc:Literal>
+        </ogc:PropertyIsEqualTo>
+    </xsl:template>    
+    
+    
+    
+</xsl:stylesheet>

+ 31 - 0
SE/schema/default_db_xml_cache.public/p5_simpleSchema_map/element-filename.xsl

@@ -0,0 +1,31 @@
+<?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:p5_simpleSchema_map="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/p5_simpleSchema_map.xsd"
+    xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
+    exclude-result-prefixes="xs"
+    version="2.0">
+    
+    
+    
+    <xsl:param name="p5_simpleSchema_map:simpleSchema.local" select="concat($default_db.instance.xml,'/simpleSchema/')"/> <!-- file:/Users/a.binder/Documents/xmlschema_procesy5/src-xmlschema/public_html/default_db.instance.xml/simpleSchema/ -->
+    
+    
+    <xsl:function name="p5_simpleSchema_map:element-filename">
+        <!-- go_recurse_from_root_by_build_element_cache , go_recurse_from_root_by_build_complexType ,  -->
+        <xsl:param name="parent_type"/> 
+        <xsl:param name="namespace_uri_param"/>
+        
+        <xsl:choose>
+            <xsl:when test="substring-before(system_cache__appinfo:translate_object_escaped_prefix_from_string(system_cache__appinfo:prefix_from_targetNamespace( $system_cache__appinfo:vrtfNamespaces,$namespace_uri_param )),':')">
+                <xsl:value-of select="concat($p5_simpleSchema_map:simpleSchema.local,'/', system_cache__appinfo:get_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string(system_cache__appinfo:prefix_from_targetNamespace( $system_cache__appinfo:vrtfNamespaces,$namespace_uri_param ))),'/',system_cache__appinfo:clean_object_prefix($parent_type),'.xml')"/>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:value-of select="concat($p5_simpleSchema_map:simpleSchema.local,'/', system_cache__appinfo:prefix_from_targetNamespace( $system_cache__appinfo:vrtfNamespaces,$namespace_uri_param ),'/',system_cache__appinfo:clean_object_prefix($parent_type),'.xml')"/>
+            </xsl:otherwise>
+        </xsl:choose>
+           
+           
+    </xsl:function>
+    
+</xsl:stylesheet>

+ 7 - 0
SE/schema/default_db_xml_cache.public/p5_tr_map/element-filename.xsl

@@ -2,11 +2,18 @@
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:p5_tr_map="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/procesy5_translate_map.xsd"
+    xmlns:p5_simpleSchema_map="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/p5_simpleSchema_map.xsd"
     xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
     exclude-result-prefixes="xs"
     version="2.0">
     
     
+    
+    
+    
+    
+    
+    
     <xsl:function name="p5_tr_map:element-filename.complete">
         <xsl:param name="objectType"/>
         <xsl:param name="parent_type"/>

+ 1 - 0
SE/schema/default_db_xml_cache.public/system_cache__appinfo/element-filename.xsl

@@ -137,6 +137,7 @@
     </xsl:function>
     
     
+    
     <xsl:function name="system_cache__appinfo:element-filename-prefixed.symlink">
         <xsl:param name="objectType"/> <!-- build_element , build_complexType , go_recurse_from_root_by_build_element_cache , p5_tr_map:go_recurse_from_root_by_build_complexType ,  -->
         <xsl:param name="element"/>

+ 12 - 0
SE/schema/default_db_xml_cache.public/system_cache__appinfo/escape_functions.xsl

@@ -17,6 +17,18 @@
         </xsl:choose>
     </xsl:function>
     
+    <xsl:function name="system_cache__appinfo:get_object_prefix.on_error_empty">
+        <xsl:param name="name" />
+        <xsl:choose>
+            <xsl:when test="substring-before($name,':')">
+                <xsl:value-of select="substring-before($name,':')"/>
+            </xsl:when>
+            <xsl:otherwise>
+                <!--<xsl:value-of select="$name"/>-->
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:function>
+    
     <xsl:function name="system_cache__appinfo:clean_object_prefix">
         <xsl:param name="name" />
         <xsl:choose>

+ 18 - 6
SE/schema/default_db_xml_cache.public/system_cache__appinfo/external_schema_targetNamespace.xsl

@@ -87,12 +87,15 @@
         </xsl:variable>
         <xsl:choose>
             <xsl:when test="contains($schema.targetNamespace,$zasob_id_db_targetNamespace_detect_string)">
+                <xsl:message>#90-A contains($schema.targetNamespace,$zasob_id_db_targetNamespace_detect_string)</xsl:message>
                 <xsl:value-of select="concat($external_schema_table.path,'/',$schema_save_path,'/',$schema.prefix,'.xsd')"/>
             </xsl:when>
             <xsl:when test="system_cache__appinfo:get_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($schema.prefix))=$targetNamespace_DEFAULTS_prefix"> 
+                <xsl:message>#90-B system_cache__appinfo:get_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($schema.prefix))=$targetNamespace_DEFAULTS_prefix</xsl:message>
                 <xsl:value-of select="concat($external_schema_table.path,'/',$schema_save_path,'/',system_cache__appinfo:root_obj_name($system_cache__appinfo:document-uri-orig),'.xsd')"/>
             </xsl:when>
             <xsl:otherwise>
+                <xsl:message>#90-C-else concat($external_schema_table.path,'/',$schema_save_path,'.xsd')</xsl:message>
                 <xsl:value-of select="concat($external_schema_table.path,'/',$schema_save_path,'.xsd')"/>
             </xsl:otherwise>
         </xsl:choose>
@@ -105,11 +108,12 @@
         <xsl:choose>
             <xsl:when test="contains($schema.targetNamespace,$zasob_id_db_targetNamespace_detect_string)">
                 <xsl:message>#73-A saving to zasob_db = <xsl:value-of select="$schema.prefix"/> table $zasob_id_db_targetNamespace_detect_string=<xsl:value-of select="$zasob_id_db_targetNamespace_detect_string"/>  $system_cache__appinfo:document-uri-orig = <xsl:value-of select="$system_cache__appinfo:document-uri-orig"/> ; $schema.prefix=<xsl:value-of select="$schema.prefix"/></xsl:message>
-                <xsl:value-of select="system_cache__appinfo:get_object_prefix_from_escaped_prefix_or_not_being_escaped($schema.prefix)"/>
-            </xsl:when>
+                <xsl:value-of select="system_cache__appinfo:get_object_prefix_from_escaped_prefix($schema.prefix)"/>
+            </xsl:when> <!-- system_cache__appinfo:get_object_prefix_from_escaped_prefix_or_not_being_escaped -->
             <xsl:when test="system_cache__appinfo:get_object_prefix_from_escaped_prefix_or_not_being_escaped($schema.prefix)=$targetNamespace_DEFAULTS_prefix">
+                <xsl:message>#73-B1 debug $schema.prefix=$targetNamespace_DEFAULTS_prefix == <xsl:value-of select="$schema.prefix"/>=<xsl:value-of select="$targetNamespace_DEFAULTS_prefix"/>;</xsl:message>
                 <xsl:variable name="root_obj_name" select=" system_cache__appinfo:root_obj_name($system_cache__appinfo:document-uri-orig)"/>
-                <xsl:message>#73-B saving to default_db table $default_db_targetNamespace_detect_string=<xsl:value-of select="$default_db_targetNamespace_detect_string"/> $root_obj_name=<xsl:value-of select="$root_obj_name"/>  $targetNamespace_DEFAULTS_prefix <xsl:value-of select="$targetNamespace_DEFAULTS_prefix"/>; $system_cache__appinfo:document-uri-orig = <xsl:value-of select="$system_cache__appinfo:document-uri-orig"/> ; $schema.prefix=<xsl:value-of select="$schema.prefix"/></xsl:message>
+                <xsl:message>#73-B2 saving to default_db table $default_db_targetNamespace_detect_string=<xsl:value-of select="$default_db_targetNamespace_detect_string"/> $root_obj_name=<xsl:value-of select="$root_obj_name"/>  $targetNamespace_DEFAULTS_prefix <xsl:value-of select="$targetNamespace_DEFAULTS_prefix"/>; $system_cache__appinfo:document-uri-orig = <xsl:value-of select="$system_cache__appinfo:document-uri-orig"/> ; $schema.prefix=<xsl:value-of select="$schema.prefix"/></xsl:message>
                 <xsl:value-of select="$targetNamespace_DEFAULTS_prefix"/>
             </xsl:when>
             <xsl:otherwise>
@@ -211,6 +215,12 @@
         <!--<xsl:param name="root_complextype" />-->
         <xsl:param name="name" /><!-- element name  -->
         <xsl:param name="schema.targetNamespace" />
+        
+        <!--<xsl:if test=" number($debug) &gt;3">-->
+            <xsl:message>#216# params: $system_cache__appinfo:document-uri-orig=<xsl:value-of select="$system_cache__appinfo:document-uri-orig"/>;
+                $schema.prefix=<xsl:value-of select="$schema.prefix"/>; $name=<xsl:value-of select="$name"/>; $schema.targetNamespace=<xsl:value-of select="$schema.targetNamespace"/>;
+            </xsl:message>
+        <!--</xsl:if>-->
         <xsl:variable name="schema_save_path">
             <xsl:call-template name="system_cache__appinfo:object_install_se_ant_object.save-path">
                 <xsl:with-param name="schema.prefix" select="$schema.prefix"/>
@@ -227,12 +237,13 @@
         </xsl:variable>-->
         
         <xsl:choose>
-            <xsl:when test="system_cache__appinfo:get_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($schema.prefix))=$targetNamespace_DEFAULTS_prefix"> 
+            <xsl:when test="system_cache__appinfo:get_object_prefix.on_error_empty(system_cache__appinfo:translate_object_escaped_prefix_from_string($schema.prefix))=$targetNamespace_DEFAULTS_prefix">
+                <xsl:message>#237-A is in $schema.prefix=$targetNamespace_DEFAULTS_prefix=<xsl:value-of select="$targetNamespace_DEFAULTS_prefix"/>==<xsl:value-of select="$schema.prefix"/></xsl:message>
                 <!--<xsl:value-of select="concat($external_schema_table.path,'/',$schema_save_path,'/',system_cache__appinfo:root_obj_name($system_cache__appinfo:document-uri-orig),'.xsd')"/>-->
-                <xsl:value-of select="concat('../../',  system_cache__appinfo:get_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($schema.prefix)),'/', replace(  system_cache__appinfo:translate_object_escaped_prefix_from_string($schema.prefix),':','.'),'/',$name,'/',$name,'.xsd')"/>
+                <xsl:value-of select="concat('../../',  system_cache__appinfo:get_object_prefix.on_error_empty(system_cache__appinfo:translate_object_escaped_prefix_from_string($schema.prefix)),'/', replace(  system_cache__appinfo:translate_object_escaped_prefix_from_string($schema.prefix),':','.'),'/',$name,'/',$name,'.xsd')"/>
             </xsl:when>
             <xsl:otherwise>
-                <xsl:value-of select="concat('../../','ant-object','/',  system_cache__appinfo:get_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($schema.prefix)),'/', replace(  system_cache__appinfo:translate_object_escaped_prefix_from_string($schema.prefix),':','.'),'/',$name,'/',$name,'.xsd')"/>
+                <xsl:value-of select="concat('../../','ant-object','/',  system_cache__appinfo:get_object_prefix.on_error_empty(system_cache__appinfo:translate_object_escaped_prefix_from_string($schema.prefix)),'/', replace(  system_cache__appinfo:translate_object_escaped_prefix_from_string($schema.prefix),':','.'),'/',$name,'/',$name,'.xsd')"/>
             </xsl:otherwise>
         </xsl:choose>
         
@@ -250,6 +261,7 @@
         <xsl:param name="system_cache__appinfo:xpath"/> <!-- like p5_zasob_17666:sys_users/UserId -->
         <xsl:variable name="result" select=" substring-before($system_cache__appinfo:xpath,'/')"/>
         <xsl:if test="string-length($result) &lt; 1"><xsl:message terminate="yes">#92 incorrect arg=(<xsl:value-of select="$system_cache__appinfo:xpath"/>) should be like p5_zasob_17666:sys_users/UserId</xsl:message></xsl:if>
+        <!--<xsl:if test="number($debug_level) &gt;3"><xsl:message>#260 cleaning prefix for $result=<xsl:value-of select="$result"/></xsl:message></xsl:if>-->
         <xsl:value-of select=" system_cache__appinfo:clean_object_prefix($result)"/>
     </xsl:function>
     

+ 17 - 1
SE/schema/default_db_xml_cache.public/system_cache__appinfo/functions.xsl

@@ -43,10 +43,26 @@
     <!-- funkcja do wyczyszczenia wyescapowenago prefixu z np. default_db__x3A__IN7_DZIENNIK_KORESP do IN7_DZIENNIK_KORESP -->
     <xsl:function name="system_cache__appinfo:clean_object_escaped_prefix">
         <xsl:param name="name" />
-        <xsl:value-of select=" system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name))"/>
+        <xsl:choose>
+            <xsl:when test="contains(system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name)),':')">
+                <!--<xsl:message terminate="yes">#48 ERROR ERROR?? double prefixed or uncorrect object $name=<xsl:value-of select="$name"/>; try system_cache__appinfo:clean_object_escaped_prefix_with_db_prefix instead?</xsl:message>-->
+                <xsl:value-of select=" system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name))"/>
+    </xsl:when>
+            <xsl:otherwise><xsl:value-of select=" system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name))"/></xsl:otherwise>
+        </xsl:choose>
+        
     </xsl:function>
     
     
+<xsl:function name="system_cache__appinfo:clean_object_escaped_prefix_with_db_prefix">    
+        <xsl:param name="name" />    
+         <xsl:choose>
+            <xsl:when test="contains(system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name)),':')">
+                <xsl:value-of select="system_cache__appinfo:clean_object_escaped_prefix(system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name)))"/>
+            </xsl:when>
+            <xsl:otherwise><xsl:value-of select=" system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name))"/></xsl:otherwise>
+        </xsl:choose>
+    </xsl:function>
     
    
     

+ 26 - 0
SE/schema/default_db_xml_cache.public/system_cache__resources_tree_generate_xsl_required_occurs_raport/element-filename.xsl

@@ -32,4 +32,30 @@
     </xsl:function>
     
     
+    
+    <xsl:function name="system_cache__resources_tree_generate_xsl_required_occurs_raport:element-filename.nocache">
+        <xsl:param name="system_cache__appinfo:document-uri-orig"/>
+        <xsl:param name="schema.targetNamespace"/>
+        <xsl:param name="local-name"/>
+        <xsl:param name="name"/>
+        <xsl:variable name="system_cache__appinfo:document-uri-orig">
+            <xsl:choose>
+                <xsl:when test="substring-after($system_cache__appinfo:document-uri-orig,'file:/')">
+                    <xsl:value-of select="substring-after($system_cache__appinfo:document-uri-orig,'file:/')"/>
+                </xsl:when>
+                <xsl:otherwise>
+                    <xsl:value-of select="$system_cache__appinfo:document-uri-orig"/>
+                </xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
+        <xsl:variable name="element-cache-output">
+            <xsl:call-template name="system_cache__appinfo:object_install_se_ant_object.save-path">
+                <xsl:with-param name="schema.prefix" select="system_cache__appinfo:prefix_from_targetNamespace($system_cache__appinfo:vrtfNamespaces,$schema.targetNamespace)"/>
+                <xsl:with-param name="schema.targetNamespace" select="$schema.targetNamespace"/>
+                <xsl:with-param name="system_cache__appinfo:document-uri-orig" select="$system_cache__appinfo:document-uri-orig"/>
+            </xsl:call-template>
+        </xsl:variable>
+        <xsl:value-of select="concat($detect_resource_type.local,'/',$local-name,'-',$element-cache-output,'-',$name,'.xml')"/>
+    </xsl:function>
+    
 </xsl:stylesheet>

+ 8 - 1
SE/schema/default_db_xml_cache.public/xinclude_p5_recurse/xinclude_p5_recurse.xsl

@@ -18,6 +18,8 @@
     <xsl:include href="../system_cache__appinfo/basedir.xsl"/><!-- for <xsl:param name="basedir" required="yes"/> -->
     <xsl:include href="../system_cache__appinfo/default_db.instance.xml.xsl"/> <!-- for param name="default_db.instance.xml" required="yes" file:/Users/a.binder/Documents/xmlschema_procesy5/src-xmlschema/public_html/default_db.instance.xml/ -->
     
+    <xsl:param name="xp5r:xinclude_p5_recurse.cache_dir" select="concat($default_db.instance.xml,'/xinclude_p5_recurse/')"/>
+    
     <xsl:template match="xp5r:cache" mode="xp5r:verify"/><!-- Todo to verify integrity -->
     
     <xsl:template match="xp5r:cache" >
@@ -46,6 +48,11 @@
     </xsl:template><!-- Todo to read normally data as regular file -->
     
     
+    <xsl:template match="xp5r:cache" mode="xp5r:stylecheet_compile_for_build"> <!-- to analyze stylesheet and compile it to be executed by ANT with params based on build_SE.properties.xml.xsl -->
+        <xsl:variable name="stylesheet.doc" select=""/>
+    </xsl:template>
+    
+    
     <xsl:template match="xsl:stylesheet" mode="xp5r:xslt.params"/> <!-- to parse stylesheets relations to retrieve expected params to make ant build to postprocess -->
     
     <!--<xsl:function name="xp5r:cache_dir">
@@ -55,7 +62,7 @@
     </xsl:function>-->
     
     <xsl:template mode="xp5r:cache_dir" match="xp5r:cache">
-        <xsl:value-of select="$default_db.instance.xml"/><xsl:text>/xinclude_p5_recurse/</xsl:text>
+        <xsl:value-of select="$xp5r:xinclude_p5_recurse.cache_dir"/>/xinclude_p5_recurse/
         <xsl:value-of select="system_cache__appinfo:translate_object_escaped_prefix_from_string(xp5r:apply-template/@mode)"/>
         <xsl:value-of select="system_cache__appinfo:translate_object_escaped_prefix_from_string(xp5r:apply-template/@name)"/>
             <xsl:value-of select="'/'"/><xsl:value-of select="@xp5r:id"/>