faultmsg.xsl 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2005, 2011
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fm="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/faultmsg/" xmlns:out="dummy-uri">
  13. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  14. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  15. <xsl:template match="fm:get-fault-msg">
  16. <out:template name="get-fault-msg">
  17. <out:param name="response"/>
  18. <out:choose>
  19. <!--======================= header fault =======================-->
  20. <out:when test="$response//SOAP-ENV:Fault/faultcode = 'SOAP-ENV:MustUnderstand'">
  21. <!-- SOAP Header fault -->
  22. <out:apply-templates select="$response//SOAP-ENV:Header/faults:Misunderstood"/>
  23. </out:when>
  24. <out:otherwise>
  25. <!-- SOAP Body fault -->
  26. <out:apply-templates select="$response//SOAP-ENV:Fault"/>
  27. </out:otherwise>
  28. </out:choose>
  29. </out:template>
  30. <!-- handle a SOAP header fault -->
  31. <out:template match="faults:Misunderstood">
  32. <out:choose>
  33. <out:when test="descendant::*[local-name()='errorCode'] = '-38'">
  34. <!-- in this case show all the error messages -->
  35. <out:for-each select="descendant::*[local-name() = 'detail' or local-name() = 'errorDetail' or local-name() = 'errorMessage']">
  36. <out:if test="string-length(normalize-space(.)) > 0">
  37. <error>
  38. <out:value-of select="normalize-space(.)"/>
  39. </error>
  40. </out:if>
  41. </out:for-each>
  42. </out:when>
  43. <out:otherwise>
  44. <error>
  45. <out:value-of select="descendant::*[local-name() = 'errorMessage']"/>
  46. </error>
  47. <out:for-each select="descendant::*[local-name() = 'detail' or local-name() = 'errorDetail']">
  48. <out:if test="string-length(normalize-space(.)) > 0">
  49. <error>
  50. <out:value-of select="normalize-space(.)"/>
  51. </error>
  52. </out:if>
  53. </out:for-each>
  54. </out:otherwise>
  55. </out:choose>
  56. </out:template>
  57. <!-- handle a SOAP body fault -->
  58. <out:template match="SOAP-ENV:Fault">
  59. <out:choose>
  60. <out:when test="descendant::*[local-name() = 'exception']">
  61. <out:for-each select="descendant::*[local-name() = 'exception']">
  62. <error>
  63. <out:value-of select="@errorCode"/>
  64. <out:text>-</out:text>
  65. <out:choose>
  66. <out:when test="@errorCodeString != ''">
  67. <out:value-of select="@errorCodeString"/>
  68. </out:when>
  69. <out:otherwise>
  70. <out:value-of select="./bus:message"/>
  71. </out:otherwise>
  72. </out:choose>
  73. </error>
  74. </out:for-each>
  75. </out:when>
  76. <out:otherwise>
  77. <out:for-each select="*[local-name() = 'detail']/descendant::text()">
  78. <out:if test="string-length(normalize-space(.)) > 0">
  79. <error>
  80. <out:value-of select="normalize-space(.)"/>
  81. </error>
  82. <test/>
  83. </out:if>
  84. </out:for-each>
  85. </out:otherwise>
  86. </out:choose>
  87. </out:template>
  88. </xsl:template>
  89. <xsl:template match="*">
  90. <xsl:copy>
  91. <xsl:copy-of select="@*"/>
  92. <xsl:apply-templates/>
  93. </xsl:copy>
  94. </xsl:template>
  95. </xsl:stylesheet>