p5pckg.xsl 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  4. xmlns:p5pckg="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/procesy5_package.xsd"
  5. exclude-result-prefixes="xs" version="2.0">
  6. <xsl:output indent="yes"/>
  7. <xsl:strip-space elements="*"/>
  8. <xsl:template mode="p5pckg:superedit-INSTALL_SES_PROCESY_A.php.analyze.xml"
  9. match="p5pckg.superedit-INSTALL_SES_PROCESY_A.php.xml"
  10. xpath-default-namespace="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/procesy5_package.xsd">
  11. <p5pckg:superedit-INSTALL_SES_PROCESY_A.php.analyze.xml>
  12. <xsl:variable name="context.prev" select="."/>
  13. <xsl:for-each select="tokenize(text(), '\\/\*')">
  14. <comment_in>
  15. <xsl:attribute name="pos" select="position()"/>
  16. <xsl:variable name="context.prev" select="."/>
  17. <xsl:for-each select="tokenize(current(), '\\/\*')">
  18. <xsl:attribute name="pos" select="position()"/>
  19. <comment_out>
  20. <xsl:variable name="context.prev" select="."/>
  21. <xsl:for-each select="tokenize(current(),'static')">
  22. <static>
  23. <xsl:attribute name="pos" select="position()"/>
  24. <xsl:attribute name="val" select="'static'"/>
  25. <xsl:if test="contains($context.prev,'static')">
  26. <xsl:attribute name="val.used" select="'static'"/>
  27. </xsl:if>
  28. <xsl:variable name="context.prev" select="."/>
  29. <xsl:for-each select="tokenize(current(),'function')">
  30. <function>
  31. <xsl:attribute name="pos" select="position()"/>
  32. <xsl:attribute name="val" select="'function'"/>
  33. <xsl:if test="contains($context.prev,'function')">
  34. <xsl:attribute name="val.used" select="'function'"/>
  35. </xsl:if>
  36. <xsl:variable name="context.prev" select="."/>
  37. <xsl:for-each select="tokenize(current(), '\{')">
  38. <lt>
  39. <xsl:attribute name="pos" select="position()"/>
  40. <xsl:attribute name="val" select="'{'"/>
  41. <xsl:if test="contains($context.prev,'{')">
  42. <xsl:attribute name="val.used" select="'{'"/>
  43. </xsl:if>
  44. <xsl:variable name="context.prev" select="."/>
  45. <xsl:for-each select="tokenize(current(), '}')">
  46. <rt>
  47. <xsl:attribute name="pos" select="position()"/>
  48. <xsl:attribute name="val" select="'}'"/>
  49. <xsl:if test="contains($context.prev,'}')">
  50. <xsl:attribute name="val.used" select="'}'"/>
  51. </xsl:if>
  52. <xsl:variable name="context.prev" select="."/>
  53. <!-- <xsl:for-each select="tokenize(current(), '\n')">
  54. <nl>
  55. <xsl:attribute name="val" select="'\n'"/>
  56. <xsl:attribute name="pos" select="position()"/>
  57. <xsl:variable name="escaped" select="'(//.*)'"/>
  58. <xsl:choose>
  59. <xsl:when test="matches( current(),$escaped)">
  60. <xsl:comment><xsl:value-of select="current()"/></xsl:comment>
  61. </xsl:when>
  62. <xsl:otherwise>-->
  63. <!--<xsl:variable name="context.prev" select="."/>-->
  64. <xsl:for-each select="tokenize(current(),'\(')">
  65. <lb>
  66. <xsl:attribute name="pos" select="position()"/>
  67. <xsl:attribute name="val" select="'('"/>
  68. <xsl:if test="contains($context.prev,'(')">
  69. <xsl:attribute name="val.used" select="'('"/>
  70. </xsl:if>
  71. <xsl:variable name="context.prev" select="."/>
  72. <xsl:for-each select="tokenize(current(),'\)')">
  73. <rb>
  74. <xsl:attribute name="pos" select="position()"/>
  75. <xsl:attribute name="val" select="')'"/>
  76. <xsl:if test="contains($context.prev,')')">
  77. <xsl:attribute name="val.used" select="')'"/>
  78. </xsl:if>
  79. <xsl:variable name="escape" select="';'"/>
  80. <xsl:variable name="context.prev" select="."/>
  81. <xsl:for-each select="tokenize(current(),$escape)">
  82. <command>
  83. <xsl:attribute name="pos" select="position()"/>
  84. <xsl:attribute name="val" select="$escape"/>
  85. <xsl:if test="contains($context.prev,$escape)">
  86. <xsl:attribute name="val.used" select="$escape"/>
  87. </xsl:if>
  88. <xsl:variable name="escape" select="'='"/>
  89. <xsl:variable name="context.prev" select="."/>
  90. <xsl:for-each select="tokenize(current(),$escape)">
  91. <equal>
  92. <xsl:attribute name="pos" select="position()"/>
  93. <xsl:attribute name="val" select="$escape"/>
  94. <xsl:if test="contains($context.prev,$escape)">
  95. <xsl:attribute name="val.used" select="$escape"/>
  96. </xsl:if>
  97. <xsl:variable name="escape" select="'\$'"/>
  98. <xsl:variable name="context.prev" select="."/>
  99. <xsl:for-each select="tokenize(current(),$escape)">
  100. <dollar>
  101. <xsl:attribute name="pos" select="position()"/>
  102. <xsl:attribute name="val" select="$escape"/>
  103. <xsl:if test="contains($context.prev,$escape)">
  104. <xsl:attribute name="val.used" select="$escape"/>
  105. </xsl:if>
  106. <xsl:value-of select="."/>
  107. </dollar>
  108. </xsl:for-each>
  109. </equal>
  110. </xsl:for-each>
  111. </command>
  112. </xsl:for-each>
  113. </rb>
  114. </xsl:for-each>
  115. </lb>
  116. </xsl:for-each>
  117. <!-- </xsl:otherwise>
  118. </xsl:choose>
  119. </nl>
  120. </xsl:for-each>-->
  121. </rt>
  122. </xsl:for-each>
  123. </lt>
  124. </xsl:for-each>
  125. </function>
  126. </xsl:for-each>
  127. </static>
  128. </xsl:for-each>
  129. </comment_out>
  130. </xsl:for-each>
  131. </comment_in>
  132. </xsl:for-each>
  133. </p5pckg:superedit-INSTALL_SES_PROCESY_A.php.analyze.xml>
  134. </xsl:template>
  135. <!-- <xsl:variable name="context.prev" select="."/>
  136. <xsl:for-each select="tokenize(current(),'=')">
  137. <equal>
  138. <xsl:attribute name="pos" select="position()"/>
  139. <xsl:attribute name="val" select="'='"/>
  140. <xsl:if test="contains($context.prev,'=')">
  141. <xsl:attribute name="val.used" select="'='"/>
  142. </xsl:if>
  143. <xsl:variable name="context.prev" select="."/>
  144. <xsl:for-each select="tokenize(current(),'\[')">
  145. <lqb>
  146. <xsl:if test="contains($context.prev,'[')">
  147. <xsl:attribute name="val.used" select="'['"/>
  148. </xsl:if>
  149. <xsl:attribute name="pos" select="position()"/>
  150. <xsl:attribute name="val" select="'['"/>
  151. <xsl:variable name="context.prev" select="."/>
  152. <xsl:for-each select="tokenize(current(),'\]')">
  153. <rqb>
  154. <xsl:attribute name="pos" select="position()"/>
  155. <xsl:attribute name="val" select="']'"/>
  156. <xsl:if test="contains($context.prev,']')">
  157. <xsl:attribute name="val.used" select="']'"/>
  158. </xsl:if>
  159. <xsl:variable name="esape"><xsl:text>'</xsl:text></xsl:variable>
  160. <xsl:variable name="context.prev" select="."/>
  161. <xsl:for-each select="tokenize(current(),$esape)">
  162. <apo>
  163. <xsl:attribute name="pos" select="position()"/>
  164. <xsl:attribute name="val" select="$esape"/>
  165. <xsl:if test="contains($context.prev,$esape)">
  166. <xsl:attribute name="val.used" select="$esape"/>
  167. </xsl:if>
  168. <xsl:variable name="esape"><xsl:text>"</xsl:text></xsl:variable>
  169. <xsl:variable name="context.prev" select="."/>
  170. <xsl:for-each select="tokenize(current(),$esape)">
  171. <quot>
  172. <xsl:if test="contains($context.prev,$esape)">
  173. <xsl:attribute name="val.used" select="$esape"/>
  174. </xsl:if>
  175. <xsl:attribute name="pos" select="position()"/>
  176. <xsl:attribute name="val" select="$esape"/>
  177. <xsl:value-of select="."/>
  178. </quot>
  179. </xsl:for-each>
  180. </apo>
  181. </xsl:for-each>
  182. </rqb>
  183. </xsl:for-each>
  184. </lqb>
  185. </xsl:for-each>
  186. </equal>
  187. </xsl:for-each>
  188. -->
  189. <!--
  190. <xsl:template mode="p5pckg:superedit-INSTALL_SES_PROCESY_A.php.analyze.xml"
  191. match="nl[matches('(\\/\\/.*)', text())]">
  192. <comment>
  193. <xsl:value-of select="text()"/>
  194. </comment>
  195. </xsl:template>
  196. <xsl:template mode="p5pckg:superedit-INSTALL_SES_PROCESY_A.php.analyze.xml" match="nl">
  197. <rest>
  198. <xsl:value-of select="text()"/>
  199. </rest>
  200. </xsl:template>-->
  201. <xsl:template mode="p5pckg:superedit-INSTALL_SES_PROCESY_A.php.analyze-flat.xml" match="p5pckg:superedit-INSTALL_SES_PROCESY_A.php.analyze.xml">
  202. <p5pckg:superedit-INSTALL_SES_PROCESY_A.php.analyze-flat.xml>
  203. <xsl:for-each select=".//*">
  204. <xsl:copy>
  205. <xsl:attribute name="p5pckg:pos.anal" select="position()"/>
  206. <xsl:copy-of select="@*"/>
  207. <xsl:copy-of select="text()"/>
  208. </xsl:copy>
  209. </xsl:for-each>
  210. </p5pckg:superedit-INSTALL_SES_PROCESY_A.php.analyze-flat.xml>
  211. </xsl:template>
  212. <xsl:template mode="p5pckg:superedit-INSTALL_SES_PROCESY_A.php.analyze-functions-modules.xml" match="p5pckg:superedit-INSTALL_SES_PROCESY_A.php.analyze.xml">
  213. <p5pckg:superedit-INSTALL_SES_PROCESY_A.php.analyze-functions-modules.xml>
  214. <xsl:for-each select=".//function[@val.used and .//text()]">
  215. <p5pckg:function>
  216. <xsl:attribute name="name" select="(.//text())[1]"/>
  217. <xsl:for-each select=".//command[@val.used ]">
  218. <xsl:choose>
  219. <xsl:when test=".//dollar[ contains( text(),'port install')]">
  220. <p5pckg:port1>
  221. <xsl:attribute name="install" select="equal[@pos=2 ]/substring-after(dollar[@pos=1]/text(),'install')"/>
  222. </p5pckg:port1>
  223. </xsl:when>
  224. <xsl:when test=".//dollar[ contains( text(),'port install')]">
  225. <p5pckg:port2>
  226. <xsl:attribute name="install" select="equal[@pos=2]/substring-after(dollar/text(),'install')"/>
  227. </p5pckg:port2>
  228. </xsl:when>
  229. <xsl:when test=".//dollar[@pos=2][ contains( text(),'rsh')]">
  230. <p5pckg:command>
  231. <xsl:attribute name="rsh" select="equal[@pos=2]/dollar/text()"/>
  232. </p5pckg:command>
  233. </xsl:when>
  234. </xsl:choose>
  235. </xsl:for-each>
  236. </p5pckg:function>
  237. </xsl:for-each>
  238. </p5pckg:superedit-INSTALL_SES_PROCESY_A.php.analyze-functions-modules.xml>
  239. </xsl:template>
  240. </xsl:stylesheet>