toposerver.xsl 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ################################################################################
  4. # HPCC SYSTEMS software Copyright (C) 2019 HPCC Systems®.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. ################################################################################
  18. -->
  19. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  20. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
  21. <xsl:param name="process" select="'toposerver'"/>
  22. <xsl:param name="instance" select="'s1'"/>
  23. <xsl:param name="isLinuxInstance" select="0"/>
  24. <xsl:param name="outputFilePath" select="'toposerver.xml'"/>
  25. <xsl:param name="tempPath" select="'c:\temp\'"/>
  26. <xsl:variable name="oldPathSeparator">
  27. <xsl:choose>
  28. <xsl:when test="$isLinuxInstance = 1">\:</xsl:when>
  29. <xsl:otherwise>'/$'</xsl:otherwise>
  30. </xsl:choose>
  31. </xsl:variable>
  32. <xsl:variable name="newPathSeparator">
  33. <xsl:choose>
  34. <xsl:when test="$isLinuxInstance = 1">/$</xsl:when>
  35. <xsl:otherwise>'\:'</xsl:otherwise>
  36. </xsl:choose>
  37. </xsl:variable>
  38. <xsl:variable name="newPathSeparatorChar">
  39. <xsl:choose>
  40. <xsl:when test="$isLinuxInstance = 1">'/'</xsl:when>
  41. <xsl:otherwise>'\'</xsl:otherwise>
  42. </xsl:choose>
  43. </xsl:variable>
  44. <xsl:variable name="toposerverNode" select="/Environment/Software/TopoServerProcess[@name=$process]"/>
  45. <xsl:variable name="instanceNode" select="$toposerverNode/Instance[@name=$instance]"/>
  46. <xsl:template match="/">
  47. <xsl:if test="not($toposerverNode)">
  48. <xsl:message terminate="yes">Topology Server '<xsl:value-of select="$process"/>' is undefined!</xsl:message>
  49. </xsl:if>
  50. <xsl:if test="not($instanceNode)">
  51. <xsl:message terminate="yes">Invalid instance '<xsl:value-of select="$instance"/></xsl:message>
  52. </xsl:if>
  53. <xsl:apply-templates select="$toposerverNode"/>
  54. </xsl:template>
  55. <xsl:template match="TopoServerProcess">
  56. <TopoServerProcess>
  57. <xsl:apply-templates select="@*[string(.) != '']"/>
  58. <xsl:copy-of select="/Environment/Software/Directories"/>
  59. </TopoServerProcess>
  60. </xsl:template>
  61. <!--propagate the attributes that need to be copied verbatim -->
  62. <xsl:template match="@build|@name">
  63. <xsl:copy-of select="."/>
  64. </xsl:template>
  65. <!--eat attributes not needed to be generated or those which would be processed somewhere else -->
  66. <xsl:template match="@buildSet|@description"/>
  67. <!--propagate any unrecognized attributes to output-->
  68. <xsl:template match="@*">
  69. <xsl:copy-of select="."/>
  70. </xsl:template>
  71. <xsl:template match="text()"/>
  72. </xsl:stylesheet>