WsOnDemandServices.xslt 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ################################################################################
  4. # HPCC SYSTEMS software Copyright (C) 2012 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. xmlns:seisint="http://seisint.com" exclude-result-prefixes="seisint">
  21. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
  22. <!--Note that this file no longer has service specific data, which has been moved into WsOnDemandServices.xml.
  23. This file loads the data file and picks the data it needs for the selected service and mode-->
  24. <xsl:template match="/">
  25. <xsl:for-each select="Configuration">
  26. <xsl:choose>
  27. <xsl:when test="string(@mode)!=''">
  28. <xsl:apply-templates select="."/>
  29. </xsl:when>
  30. <xsl:otherwise>
  31. <xsl:call-template name="message">
  32. <xsl:with-param name="text">Please define a valid mode for <xsl:value-of select="@name"/> service. </xsl:with-param>
  33. </xsl:call-template>
  34. <xsl:copy>
  35. <xsl:copy-of select="@name"/>
  36. </xsl:copy>
  37. </xsl:otherwise>
  38. </xsl:choose>
  39. </xsl:for-each>
  40. </xsl:template>
  41. <xsl:template match="/Configuration">
  42. <xsl:variable name="mode" select="@mode"/>
  43. <xsl:variable name="status" select="@status"/>
  44. <xsl:if test="$mode != 'Normal' and $mode != 'ESDL' and $mode != 'Boolean' and $mode!='ESDLBoolean' and $mode != 'Focus' and $mode!='ESDLFocus'">
  45. <xsl:message terminate="yes">Configuration has invalid mode '<xsl:value-of select="$mode"/>'. Valid choices are Normal, ESDL, Boolean, ESDLBoolean, Focus and ESDLFocus.</xsl:message>
  46. </xsl:if>
  47. <xsl:variable name="realMode">
  48. <xsl:choose>
  49. <xsl:when test="$mode='Normal' or $mode='Focus' or $mode='Boolean'">Normal</xsl:when>
  50. <xsl:otherwise>ESDL</xsl:otherwise>
  51. </xsl:choose>
  52. </xsl:variable>
  53. <xsl:variable name="svcDefs" select="document('WsOnDemandServices.xml')/Configurations"/>
  54. <xsl:if test="not($svcDefs)">
  55. <xsl:message terminate="yes">Service definition file 'WsOnDemandServices.xml' is missing or is invalid!</xsl:message>
  56. </xsl:if>
  57. <xsl:variable name="config" select="$svcDefs/*[name()=$realMode]/Configuration[@name=current()/@name]"/>
  58. <xsl:if test="not($config)">
  59. <xsl:message terminate="yes">Service '<xsl:value-of select="@name"/>' is not defined for mode '<xsl:value-of select="$realMode"/>' in the service definition file!</xsl:message>
  60. </xsl:if>
  61. <xsl:for-each select="$config">
  62. <xsl:copy>
  63. <xsl:variable name="path" select="normalize-space(@path)"/>
  64. <xsl:variable name="query" select="normalize-space(@queryname)"/>
  65. <xsl:variable name="queryname">
  66. <xsl:if test="$query!='' and not(contains($query, '.'))">
  67. <xsl:value-of select="concat($path, '.')"/>
  68. </xsl:if>
  69. <xsl:value-of select="$query"/>
  70. </xsl:variable>
  71. <xsl:attribute name="name">
  72. <xsl:value-of select="normalize-space(@name)"/>
  73. </xsl:attribute>
  74. <xsl:attribute name="path">
  75. <xsl:value-of select="$path"/>
  76. </xsl:attribute>
  77. <xsl:attribute name="queryname">
  78. <xsl:choose>
  79. <xsl:when test="string($mode)=$realMode">
  80. <xsl:value-of select="$queryname"/>
  81. </xsl:when>
  82. <xsl:when test="$mode='Focus' or $mode='ESDLFocus'">
  83. <xsl:value-of select="concat($path, '.FocusSearchService')"/>
  84. </xsl:when>
  85. <xsl:otherwise>
  86. <xsl:value-of select="concat($path, '.TextSearchService')"/>
  87. </xsl:otherwise>
  88. </xsl:choose>
  89. </xsl:attribute>
  90. <xsl:attribute name="mode">
  91. <xsl:value-of select="$mode"/>
  92. </xsl:attribute>
  93. <xsl:attribute name="status">
  94. <xsl:choose>
  95. <xsl:when test="$status!=''">
  96. <xsl:value-of select="$status"/>
  97. </xsl:when>
  98. <xsl:otherwise>available</xsl:otherwise>
  99. </xsl:choose>
  100. </xsl:attribute>
  101. <xsl:copy-of select="@roxieSince"/>
  102. </xsl:copy>
  103. </xsl:for-each>
  104. </xsl:template>
  105. <xsl:template name="message">
  106. <xsl:param name="text"/>
  107. <xsl:choose>
  108. <xsl:when test="function-available('seisint:message')">
  109. <xsl:variable name="dummy" select="seisint:message($text)"/>
  110. </xsl:when>
  111. <xsl:otherwise>
  112. <xsl:message terminate="no">
  113. <xsl:value-of select="$text"/>
  114. </xsl:message>
  115. </xsl:otherwise>
  116. </xsl:choose>
  117. </xsl:template>
  118. </xsl:stylesheet>