| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- <?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"
- exclude-result-prefixes="xs"
- xmlns:bp="https://procesy5.pl/biale_plamy-schema.xsd"
- version="2.0">
- <!--<xsl:param name=""></xsl:param>-->
-
- <xsl:variable name="ways2joins" select="doc('ways2joins.xml')"/>
-
- <xsl:output indent="yes"/>
- <xsl:strip-space elements="*"/>
- <!--example input
- <joins2ways>
- <item id="0">
- <item id="0">0</item>
- <item id="1">12135</item>
- <item id="2">29426</item>
- </item>
- <item id="1">
- <item id="0">0</item>
- <item id="1">1</item>
- <item id="2">24887</item>
- </item>
- </joins2ways>
- -->
-
- <xsl:template match="joins2ways_z_ID_Way">
- <!--<xsl:variable name="EdgeWayJoinsPair_cand">
- <xsl:apply-templates mode="joins"/>
- </xsl:variable>-->
- <!--<xsl:variable name="joins2ways_z_ID_Way" select="."/>-->
- <!--<xsl:copy-of select="$EdgeWayJoinsPair_cand"></xsl:copy-of>-->
- <!--<xsl:choose>
- <xsl:when test="$EdgeWayJoinsPair_cand/EdgeWayJoinsPair_cand[@ID_Way=current()/@ID_Way]">
- <JESTOK></JESTOK>
- </xsl:when>
- <xsl:otherwise>
-
- </xsl:otherwise>
- </xsl:choose>-->
- <!--<xsl:copy-of select="$EdgeWayJoinsPair_cand/no_EdgeWayJoinsPair"></xsl:copy-of>-->
- <xsl:variable name="guess_edges">
-
- <xsl:for-each select="item">
- <guess_join>
- <xsl:attribute name="ID_Way" select="@ID_Way"/>
- <xsl:variable name="ID_Way">
- <xsl:choose>
- <xsl:when test="@ID_Way"><xsl:value-of select="@ID_Way"/></xsl:when>
- <xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:apply-templates select="." mode="joins_not_way">
- <xsl:with-param name="ID_Way" select="$ID_Way"/>
- </xsl:apply-templates>
- </guess_join>
- </xsl:for-each>
-
- </xsl:variable>
-
- <EdgeWayJoins>
- <!--<xsl:for-each-group select="$EdgeWayJoinsPair_cand/no_EdgeWayJoinsPair" group-by="@ID_Way">
- <EdgeWayJoinsPair>
- <xsl:attribute name="ID_Way" select="@ID_Way"/>
- <xsl:variable name="ID_Way" select="@ID_Way"/>
- <xsl:variable name="Joins_miss">
- <xsl:for-each select="$joins2ways_z_ID_Way/item[@ID_Way=$ID_Way and count( child::node())>1 ]">
- <!-\- szukamy joinsa ktory ma joina do innego waysa-\->
- <xsl:variable name="Join_ID" select="@id"/>
- <xsl:for-each select="item">
- <ways>
- <xsl:attribute name="id_join" select="$Join_ID"/>
- <xsl:attribute name="id_way" select="text()"/>
- </ways>
- </xsl:for-each>
- </xsl:for-each>
- </xsl:variable>
- <xsl:copy-of select="$Joins_miss"/>
- <xsl:variable name="Ways_miss">
- <xsl:for-each select="$Joins_miss/ways">
- <xsl:variable name="id_join" select="@id_join"/>
- <xsl:variable name="id_way_test" select="@id_way"/>
- <xsl:for-each select="$ways2joins/ways2joins/item[@id=$id_way_test]/item">
- <found_joins_in_ways>
- <xsl:attribute name="id_join" select="$id_join"/>
- <xsl:attribute name="id_join_found" select="text()"/>
- </found_joins_in_ways>
- </xsl:for-each>
- </xsl:for-each>
- </xsl:variable>
- <xsl:copy-of select="$Ways_miss"/>
- <xsl:for-each select="$Ways_miss/found_joins_in_ways"> <!-\- [not(@id_join_found=$EdgeJoinFound)]-\->
- <xsl:choose>
- <xsl:when test="not($Joins_miss/ways[@id_join=current()/@id_join_found])">
- <!-\-<missed>-\->
- <!-\-<xsl:attribute name="Joins" select="@id_join"/>-\->
- <bp:Joins>
- <xsl:attribute name="Joins" select="current()/@id_join_found"/>
- </bp:Joins>
- <!-\-</missed>-\->
- </xsl:when>
- </xsl:choose>
- </xsl:for-each>
- </EdgeWayJoinsPair>
- </xsl:for-each-group>-->
- <xsl:for-each-group select="item" group-by="@ID_Way">
- <xsl:variable name="ID_Way" select="@ID_Way"/>
-
- <EdgeWayJoinsPair>
- <xsl:attribute name="ID_Way" select="@ID_Way"/>
- <!-- debug -->
- <!--<xsl:copy-of select="$guess_edges/guess_join[@ID_Way=$ID_Way]"></xsl:copy-of>-->
- <xsl:for-each select="$guess_edges/guess_join[@ID_Way=$ID_Way]/EdgeWayJoinsPair_cand">
- <bp:Joins>
- <xsl:attribute name="Joins" select="@joins"/>
- </bp:Joins>
- </xsl:for-each>
- <!--<xsl:for-each select="current-group()">
- <!-\-<GROUP><xsl:copy-of select="item("></xsl:copy-of></GROUP>-\->
- <xsl:choose>
- <xsl:when test=" position()=1 or position()=last()">
- <bp:Joins>
- <xsl:attribute name="Joins" select="@id"/>
- </bp:Joins>
- </xsl:when>
- </xsl:choose>
- </xsl:for-each>-->
- </EdgeWayJoinsPair>
- </xsl:for-each-group>
- <!--<xsl:for-each-group select="$EdgeWayJoinsPair_cand/EdgeWayJoinsPair_cand" group-by="@ID_Way">
- <EdgeWayJoinsPair>
- <xsl:attribute name="ID_Way" select="@ID_Way"/>
- <xsl:variable name="ID_Way" select="@ID_Way"/>
- <xsl:for-each select="current-group()">
- <xsl:variable name="EdgeJoinFound" select="@joins"/>
- <bp:Joins>
- <xsl:attribute name="Joins" select="@joins"/>
- </bp:Joins>
- <xsl:choose>
- <xsl:when test=" count( current-group())<2">
- <bp:Joins>
- <xsl:variable name="Joins_miss">
- <xsl:for-each select="$joins2ways_z_ID_Way/item[@ID_Way=$ID_Way and count( child::node())=2 ]">
- <!-\- szukamy joinsa ktory ma joina do innego waysa-\->
- <xsl:variable name="Join_ID" select="@id"/>
- <xsl:for-each select="item">
- <ways>
- <xsl:attribute name="id_join" select="$Join_ID"/>
- <xsl:attribute name="id_way" select="text()"/>
- </ways>
- </xsl:for-each>
- </xsl:for-each>
- </xsl:variable>
- <!-\-<xsl:copy-of select="$Joins_miss"></xsl:copy-of>-\->
- <xsl:variable name="Ways_miss">
- <xsl:for-each select="$Joins_miss/ways">
- <xsl:variable name="id_join" select="@id_join"/>
- <xsl:variable name="id_way_test" select="@id_way"/>
- <xsl:for-each select="$ways2joins/ways2joins/item[@id=$id_way_test]/item">
- <found_joins_in_ways>
- <xsl:attribute name="id_join" select="$id_join"/>
- <xsl:attribute name="id_join_found" select="text()"/>
- </found_joins_in_ways>
- </xsl:for-each>
- </xsl:for-each>
- </xsl:variable>
- <!-\-<xsl:copy-of select="$Ways_miss"/>-\->
- <xsl:for-each select="$Ways_miss/found_joins_in_ways[not(@id_join_found=$EdgeJoinFound)]">
- <xsl:choose>
- <xsl:when test="not($Joins_miss/ways[@id_join=current()/@id_join_found])">
- <!-\-<missed>-\->
- <!-\-<xsl:attribute name="Joins" select="@id_join"/>-\->
- <xsl:attribute name="Joins" select="current()/@id_join_found"/>
- <!-\-</missed>-\->
- </xsl:when>
- </xsl:choose>
- </xsl:for-each>
- </bp:Joins>
- </xsl:when>
- </xsl:choose>
- </xsl:for-each>
- </EdgeWayJoinsPair>
- </xsl:for-each-group>-->
- </EdgeWayJoins>
- </xsl:template>
-
-
- <xsl:template match="item" mode="miss_join">
-
- </xsl:template>
-
- <xsl:template match="item" mode="joins_not_way">
- <xsl:param name="ID_Way" required="yes"/>
- <xsl:variable name="count_our_way">
- <xsl:for-each select="item">
- <xsl:element name="count_our_way">
- <xsl:choose>
- <xsl:when test="@ID_WAY=$ID_Way">1</xsl:when>
- <xsl:otherwise>0</xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:for-each>
- </xsl:variable>
- <see>
- <xsl:copy-of select="."/>
- <inside>
- <xsl:attribute name="count_our" select="count(item[@ID_WAY=$ID_Way])"/>
- <count_our_way_val>
- <xsl:copy-of select="$count_our_way"/>
- </count_our_way_val>
- <xsl:for-each select="item[@ID_WAY!=$ID_Way]">
- <xsl:element name="EdgeWayJoinsPair_cand">
- <xsl:attribute name="joins" select="../@id"/>
- <xsl:attribute name="ID_Way" select="../@ID_Way"/>
- </xsl:element>
- </xsl:for-each>
- </inside>
- </see>
- <xsl:variable name="if_item_not_in_way">
- <xsl:for-each select="item">
- <xsl:choose>
- <xsl:when test="not(@ID_WAY=$ID_Way)">
- <xsl:element name="EdgeWayJoinsPair_cand">
- <xsl:attribute name="joins" select="../@id"/>
- <xsl:attribute name="ID_Way" select="../@ID_Way"/>
- </xsl:element></xsl:when>
- </xsl:choose>
-
-
- </xsl:for-each>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="count(item)=1">
- <xsl:element name="EdgeWayJoinsPair_cand">
- <xsl:attribute name="pos" select="position()"/>
- <xsl:attribute name="joins" select="@id"/>
- <xsl:attribute name="ID_Way" select="@ID_Way"/>
- <xsl:attribute name="ways" select="item/text()"/>
- </xsl:element>
- </xsl:when>
- <xsl:when test="$if_item_not_in_way/EdgeWayJoinsPair_cand and count(item[@ID_WAY=$ID_Way])<2">
- <xsl:element name="EdgeWayJoinsPair_cand">
- <xsl:attribute name="debug" select="'has other way'"/>
- <xsl:attribute name="joins" select="@id"/>
- <xsl:attribute name="ID_Way" select="@ID_Way"/>
- <xsl:attribute name="ways">
- <xsl:for-each select="item/text()">
- <xsl:value-of select=" concat(.,' ')"/>
- </xsl:for-each>
- </xsl:attribute>
- <!--<xsl:attribute name="ways" select="item/text()" separator="', '" />-->
- </xsl:element>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="item" mode="joins">
- <!--<xsl:param name="second_turn" />-->
- <xsl:choose>
- <!--<xsl:when test="count(item[@ID_WAY=current()/@ID_Way])>1">
- <xsl:element name="EdgeWayJoinsPair_cand">
- <xsl:attribute name="joins" select="@id"/>
- <xsl:attribute name="ID_Way" select="@ID_Way"/>
- <xsl:attribute name="ways" select="item/text()"/>
- </xsl:element>
- </xsl:when>-->
- <xsl:when test="count(item)=1">
- <xsl:element name="EdgeWayJoinsPair_cand">
- <xsl:attribute name="pos" select="position()"/>
- <xsl:attribute name="joins" select="@id"/>
- <xsl:attribute name="ID_Way" select="@ID_Way"/>
- <xsl:attribute name="ways" select="item/text()"/>
- </xsl:element>
- </xsl:when>
- <!--<xsl:when test="count(../item[@ID_Way=current()/@ID_Way]) and count( child::node()=1)">
- <xsl:element name="no_EdgeWayJoinsPair">
- <xsl:attribute name="ID_Way" select="@ID_Way"/>
- </xsl:element>
- </xsl:when>-->
- <!--<xsl:when test="count(item)=2">
- <xsl:element name="EdgeWayJoinsPair_cand">
- <xsl:attribute name="joins" select="@id"/>
- <xsl:attribute name="ID_Way" select="@ID_Way"/>
- <xsl:attribute name="ways" select="item/text()"/>
- </xsl:element>
- </xsl:when>-->
- </xsl:choose>
- </xsl:template>
-
-
- </xsl:stylesheet>
|