p5dkp.dita.values.xsl 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  4. xmlns:p5bws="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/WPS_Functions.xsd"
  5. xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
  6. xmlns:p5dkp="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/dita_kosztorys_projektowy/p5dkp.xsd"
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8. xmlns:p5suis="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/system_ui_info_speech/system_ui_info_speech.xsd"
  9. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  10. xmlns:p5dkp.dita.values="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/dita_kosztorys_projektowy/p5dkp.dita.values.xsd"
  11. exclude-result-prefixes="xs vc p5bws system_cache__appinfo p5dkp p5suis xsi p5dkp.dita.values"
  12. version="2.0">
  13. <xsl:output indent="yes"/>
  14. <xsl:strip-space elements="*"/>
  15. <xsl:param name="p5dkp.dita.values:xsd" required="yes"/> <!-- do parsowania asserts -->
  16. <xsl:variable name="p5dkp.dita.values.xsd" select="doc($p5dkp.dita.values:xsd)"/>
  17. <xsl:template mode="p5dkp:dita.values" match="text()|comment()"/>
  18. <xsl:template match="*[*]" mode="p5dkp:dita.values"/>
  19. <xsl:template match="*" mode="p5dkp:dita.values">
  20. <p>
  21. <ph>
  22. <xsl:value-of select="name()"/><xsl:text> : </xsl:text>
  23. </ph>
  24. <xsl:choose>
  25. <xsl:when test="@p5dkp:idref">
  26. <ph keyref="{@p5dkp:idref}"> </ph>
  27. </xsl:when>
  28. <xsl:when test="@p5dkp:id">
  29. <ph keyref="{@p5dkp:id}"> </ph>
  30. </xsl:when>
  31. <xsl:otherwise>
  32. <ph> <xsl:value-of select="text()"/> </ph>
  33. </xsl:otherwise>
  34. </xsl:choose>
  35. </p>
  36. </xsl:template>
  37. <xsl:template mode="p5dkp.dita.values:xsd" xpath-default-namespace="http://www.w3.org/2001/XMLSchema" match="import|redefine">
  38. <xsl:param name="import" required="yes"/>
  39. <xsl:param name="redefine"/>
  40. <!--<xsl:message>#50 $import =
  41. <xsl:for-each select="$import//@namespace">
  42. ==<xsl:value-of select="."/>;
  43. </xsl:for-each>;
  44. </xsl:message>-->
  45. <xsl:copy>
  46. <xsl:copy-of select="@*"/>
  47. <xsl:variable name="namespace">
  48. <xsl:choose>
  49. <xsl:when test="not(@namespace)">
  50. <xsl:value-of select="concat(../@targetNamespace,'-',tokenize(@schemaLocation,'/')[ position() = last()])"/>
  51. </xsl:when>
  52. <xsl:otherwise>
  53. <xsl:value-of select="@namespace"/>
  54. </xsl:otherwise>
  55. </xsl:choose>
  56. </xsl:variable>
  57. <xsl:variable name="import">
  58. <import>
  59. <!--<xsl:for-each select="$import//@namespace">
  60. <namespace>
  61. <xsl:attribute name="namespace" select="."/>
  62. </namespace>
  63. </xsl:for-each>-->
  64. <xsl:copy-of select="$import/import/*" xpath-default-namespace=""/>
  65. <namespace>
  66. <xsl:attribute name="namespace" select="$namespace"/>
  67. </namespace>
  68. </import>
  69. </xsl:variable>
  70. <xsl:choose>
  71. <xsl:when test=" not(matches($namespace,'p5dkp'))">
  72. <xsl:message>#71 not(matches(@namespace,'p5dkp')) = <xsl:value-of select="$namespace"/></xsl:message>
  73. </xsl:when>
  74. <xsl:when test=" count($import//*[@namespace = $namespace]) &gt; 1">
  75. <xsl:message>#74 Ignoring recurse import for @namespace=<xsl:value-of select="$namespace"/>; and @schemaLocation = <xsl:value-of select="@schemaLocation"/>;</xsl:message>
  76. </xsl:when>
  77. <xsl:otherwise>
  78. <xsl:choose>
  79. <xsl:when test="doc-available(@schemaLocation)">
  80. <xsl:message>#66 opening <xsl:value-of select="@schemaLocation"/>
  81. @namespace=<xsl:value-of select="$namespace"/>;
  82. count $import = <xsl:value-of select="count($import//*)"/> - with own @namespace = <xsl:value-of select="count($import//*[@namespace = $namespace])"/></xsl:message>
  83. <!--<xsl:message>#79 $import =
  84. <xsl:for-each select="$import//@namespace">
  85. ==<xsl:value-of select="."/>;
  86. </xsl:for-each>;
  87. </xsl:message>-->
  88. <xsl:apply-templates mode="#current" select="doc(@schemaLocation)">
  89. <xsl:with-param name="import" select="$import"/>
  90. <xsl:with-param name="redefine" select="$redefine"/>
  91. </xsl:apply-templates>
  92. </xsl:when>
  93. <xsl:otherwise>
  94. <xsl:message>#72 unaviable doc <xsl:value-of select="@schemaLocation"/></xsl:message>
  95. </xsl:otherwise>
  96. </xsl:choose>
  97. </xsl:otherwise>
  98. </xsl:choose>
  99. <xsl:apply-templates mode="#current" >
  100. <xsl:with-param name="import" select="$import"/>
  101. <xsl:with-param name="redefine" select="$redefine"/>
  102. </xsl:apply-templates>
  103. </xsl:copy>
  104. </xsl:template>
  105. <xsl:template mode="p5dkp.dita.values:xsd" xpath-default-namespace="http://www.w3.org/2001/XMLSchema" match="*">
  106. <xsl:copy>
  107. <xsl:copy-of select="@*"/>
  108. <xsl:apply-templates mode="#current"/>
  109. </xsl:copy>
  110. </xsl:template>
  111. <xsl:template mode="p5dkp.dita.values:xsd" xpath-default-namespace="http://www.w3.org/2001/XMLSchema" match="schema">
  112. <xsl:param name="import" required="yes"/>
  113. <xsl:param name="redefine"/>
  114. <xsl:copy>
  115. <xsl:copy-of select="@*"/>
  116. <xsl:apply-templates mode="#current">
  117. <xsl:with-param name="import" select="$import"/>
  118. <xsl:with-param name="redefine" select="$redefine"/>
  119. </xsl:apply-templates>
  120. </xsl:copy>
  121. </xsl:template>
  122. <xsl:template mode="p5dkp.dita.values:dita.values.xml #default" match="p5dkp:map.budzet_rola.xml">
  123. <p5dkp.dita.values:dita.values.xml xsi:noNamespaceSchemaLocation="{$p5dkp.dita.values:xsd}">
  124. <xsl:variable name="import">
  125. <import>
  126. <!--<namespace namespace="dupajasiu"/>-->
  127. </import>
  128. </xsl:variable>
  129. <xsl:variable name="redefine">
  130. <redefine/>
  131. </xsl:variable>
  132. <xsl:variable name="p5dkp.dita.values:xsd">
  133. <p5dkp.dita.values:xsd>
  134. <xsl:apply-templates mode="p5dkp.dita.values:xsd" select="$p5dkp.dita.values.xsd">
  135. <xsl:with-param name="import" select="$import"/>
  136. <xsl:with-param name="redefine" select="$redefine"/>
  137. </xsl:apply-templates>
  138. </p5dkp.dita.values:xsd>
  139. </xsl:variable>
  140. <xsl:copy-of select="$p5dkp.dita.values:xsd"/>
  141. <xsl:variable name="context" select="current()"/>
  142. <xsl:for-each select="$p5dkp.dita.values:xsd//element[@name='dita.values.xml']//sequence/*" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  143. <xsl:choose>
  144. <xsl:when test="$context/*[ name() = current()/@ref]">
  145. <xsl:message>#162 applying asserts to <xsl:value-of select="@ref"/></xsl:message>
  146. </xsl:when>
  147. <xsl:otherwise>
  148. <xsl:message>#162-B NOT FOUND to applying asserts to <xsl:value-of select="@ref"/>/name() = <xsl:value-of select="name()"/>;</xsl:message>
  149. </xsl:otherwise>
  150. </xsl:choose>
  151. </xsl:for-each>
  152. <!--<xsl:copy-of select="$p5dkp.dita.values.xsd"/>-->
  153. </p5dkp.dita.values:dita.values.xml>
  154. </xsl:template>
  155. </xsl:stylesheet>