123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: ps
- (C) Copyright IBM Corp. 2005, 2011
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <!--
- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- -->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
- xmlns:xts="http://developer.cognos.com/schemas/xts/">
-
- <!-- Fault block for handling CM faults -->
-
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
-
- <xsl:template match="/root">
- <xsl:apply-templates select="fault"/>
- </xsl:template>
-
- <xsl:template match="fault">
- <xsl:copy>
- <SOAP-ENV:Envelope>
- <xsl:choose>
- <xsl:when test="SOAP-ENV:Envelope/SOAP-ENV:Header">
- <xsl:copy-of select="SOAP-ENV:Envelope/SOAP-ENV:Header"/>
- </xsl:when>
- <xsl:otherwise>
- <SOAP-ENV:Header/>
- </xsl:otherwise>
- </xsl:choose>
- <SOAP-ENV:Body>
- <xsl:apply-templates/>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>
- </xsl:copy>
- </xsl:template>
- <xsl:template match="error">
- <xsl:choose>
- <xsl:when test="descendant::SOAP-ENV:Fault">
- <xsl:apply-templates/>
- </xsl:when>
- <xsl:otherwise>
- <!-- This section handles xts exceptions that occur as part of the xts:request such as "connection refused" -->
- <SOAP-ENV:Fault>
- <xsl:copy-of select="faultcode"/>
- <xsl:copy-of select="faultstring"/>
- <detail>
- <bus:exception>
- <xsl:choose>
- <xsl:when test="faultcode = 'Server.protocol.bibusrequestfailed'">
- <!-- Can't connect to content manager -->
- <errorCode>ccError</errorCode>
- <bus:message>
- <messageString><xts:string id="IDS_ERR_CM_CONNECT"/></messageString>
- </bus:message>
- <!-- copy the existing messages and increase their nestingLevel -->
- <xsl:call-template name="copy-xts-msg">
- <xsl:with-param name="level" select="1"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <!-- just copy the existing messages -->
- <xsl:call-template name="copy-xts-msg">
- <xsl:with-param name="level" select="0"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </bus:exception>
- </detail>
- </SOAP-ENV:Fault>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="SOAP-ENV:Fault">
- <xsl:choose>
- <xsl:when test="not(descendant::SOAP-ENV:Fault)">
- <xsl:copy>
- <xsl:copy-of select="faultcode"/>
- <xsl:copy-of select="faultstring"/>
- <detail>
- <xsl:apply-templates select="detail/bus:exception"/>
- </detail>
- </xsl:copy>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="descendant::SOAP-ENV:Fault"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="bus:exception">
- <!-- this section handles errors where the result of an xts:request is a soap fault such as cm's duplicate name error -->
- <xsl:copy>
- <xsl:copy-of select="severity"/>
- <errorCode>ccError</errorCode>
- <bus:message>
- <messageString>
- <xsl:variable name="cr"><xts:string id="IDS_ERR_CREATE"/></xsl:variable>
- <xsl:variable name="co"><xts:string id="IDS_ERR_COPY"/></xsl:variable>
- <xsl:variable name="mo"><xts:string id="IDS_ERR_MOVE"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="starts-with(errorCode, 'cmNameConflict') or starts-with(errorCode, 'cmDuplicateName')">
- <xts:string id="IDS_ERR_CM_OP_DUP"> <!-- duplicate name error -->
- <xts:param name="op">
- <xsl:variable name="op" select="/root/env/param[@name='ifrmcmd']"/>
- <xsl:choose>
- <xsl:when test="$op='create'"><xsl:value-of select="$cr"/></xsl:when>
- <xsl:when test="$op='copy'"><xsl:value-of select="$co"/></xsl:when>
- <xsl:when test="$op='move'"><xsl:value-of select="$mo"/></xsl:when>
- </xsl:choose>
- </xts:param>
- </xts:string>
- </xsl:when>
- <xsl:otherwise>
- <xts:string id="IDS_ERR_CM_OP"> <!-- generic operation failed message -->
- <xts:param name="op">
- <xsl:variable name="op" select="/root/env/param[@name='ifrmcmd']"/>
- <xsl:choose>
- <xsl:when test="$op='create'"><xsl:value-of select="$cr"/></xsl:when>
- <xsl:when test="$op='copy'"><xsl:value-of select="$co"/></xsl:when>
- <xsl:when test="$op='move'"><xsl:value-of select="$mo"/></xsl:when>
- </xsl:choose>
- </xts:param>
- </xts:string>
- </xsl:otherwise>
- </xsl:choose>
- </messageString>
- </bus:message>
- <!-- copy the existing messages and increase their nestingLevel -->
- <xsl:call-template name="copy-msg">
- <xsl:with-param name="level" select="'1'"/>
- </xsl:call-template>
- </xsl:copy>
- </xsl:template>
-
- <xsl:template name="copy-msg">
- <xsl:param name="level"/>
- <xsl:for-each select="bus:message">
- <xsl:copy>
- <nestingLevel>
- <xsl:choose>
- <xsl:when test="not(nestingLevel)">
- <xsl:value-of select="$level"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="number(nestingLevel) + number($level)"/>
- </xsl:otherwise>
- </xsl:choose>
- </nestingLevel>
- <xsl:copy-of select="messageString"/>
- </xsl:copy>
- </xsl:for-each>
- </xsl:template>
- <xsl:template name="copy-xts-msg">
- <!-- turn xts:exception into bus:message -->
- <xsl:param name="level"/>
- <xsl:for-each select="detail/xts:exception">
- <bus:message>
- <nestingLevel>
- <xsl:choose>
- <xsl:when test="not(nestingLevel)">
- <xsl:value-of select="$level"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="number(nestingLevel) + number($level)"/>
- </xsl:otherwise>
- </xsl:choose>
- </nestingLevel>
- <messageString>
- <xsl:value-of select="xts:exceptionMsg"/>
- </messageString>
- </bus:message>
- </xsl:for-each>
- </xsl:template>
-
- <xsl:template match="*">
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="text()"/>
- </xsl:stylesheet>
|