123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: cpscrn
- (C) Copyright IBM Corp. 2005, 2011
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <!-- Cognos Web Services 7.3 -->
- <!-- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved. -->
- <!-- Cognos and the Cognos logo are trademarks of Cognos ULC, (formerly Cognos Incorporated). -->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
- <xsl:variable name="info" select="/root/interface/discovery"/>
- <xsl:variable name="interface" select="/root/interface"/>
- <xsl:variable name="schemas" select="/root/schemas"/>
- <xsl:variable name="host" select="/root/http/param[@name = 'HTTP_HOST']"/>
- <xsl:variable name="script_name" select="/root/http/param[@name = 'SCRIPT_NAME']"/>
- <xsl:variable name="server" select="concat('http://', $host, $script_name, '/nav')"/>
- <xsl:output method="xml" encoding="iso-8859-1" indent="no"/>
- <xsl:template match="/">
- <xsl:apply-templates select="$info/wsdl:definitions"/>
- </xsl:template>
-
- <!-- This is needed to copy the appropriate namespaces into the output doc -->
- <xsl:template match="wsdl:definitions">
- <xsl:copy>
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates select="$info/documentation"/>
- <xsl:apply-templates select="$info"/>
- </xsl:copy>
- </xsl:template>
- <xsl:template match="documentation">
- <wsdl:documentation>
- <xsl:value-of select="."/>
- </wsdl:documentation>
- </xsl:template>
-
- <xsl:template match="discovery">
-
- <xsl:variable name="definition" select="definition"/>
- <wsdl:types>
- <xsl:apply-templates select="documentation"/>
- <xsl:apply-templates select="$schemas/*" mode="copyroot"/>
- </wsdl:types>
- <!-- header messages -->
- <xsl:for-each select="$interface/header">
- <wsdl:message name="{ @name }">
- <xsl:for-each select="message/*">
- <wsdl:part>
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates select="documentation"/>
- </wsdl:part>
- </xsl:for-each>
- </wsdl:message>
- </xsl:for-each>
- <!-- body messages -->
- <xsl:for-each select="$interface/operation[@internal != 'true']">
- <wsdl:message name="{ @name }">
- <xsl:for-each select="message/input">
- <wsdl:part name="request">
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates select="documentation"/>
- </wsdl:part>
- </xsl:for-each>
- </wsdl:message>
- <wsdl:message name="{ @name }Response">
- <xsl:for-each select="message/output">
- <wsdl:part name="response">
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates select="documentation"/>
- </wsdl:part>
- </xsl:for-each>
- </wsdl:message>
- <xsl:for-each select="message/fault">
- <xsl:if test="not(preceding::fault/@name = current()/@name)">
- <wsdl:message name="{ substring-after(@name, ':') }">
- <wsdl:part name="fault" element="{ @name }">
- <xsl:apply-templates select="documentation"/>
- </wsdl:part>
- </wsdl:message>
- </xsl:if>
- </xsl:for-each>
- </xsl:for-each>
- <wsdl:portType name="{ definition }Port">
- <xsl:for-each select="$interface/operation[@internal != 'true']">
- <wsdl:operation name="{ @name }">
- <xsl:apply-templates select="documentation"/>
- <wsdl:input message="tns:{ @name }"/>
- <wsdl:output message="tns:{ @name }Response"/>
- <xsl:for-each select="message/fault">
- <wsdl:fault message="{ @name }" name="{ substring-after(@name, ':') }">
- <xsl:apply-templates select="documentation"/>
- </wsdl:fault>
- </xsl:for-each>
- </wsdl:operation>
- </xsl:for-each>
- </wsdl:portType>
-
- <wsdl:binding name="{ definition }Binding" type="tns:{ definition }Port">
- <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
- <xsl:for-each select="$interface/operation[not(@internal = 'true')]">
- <xsl:variable name="opname" select="@name"/>
- <wsdl:operation name="{ @name }">
- <soap:operation soapAction="{ $definition }.run"/>
- <wsdl:input>
- <soap:body use="literal"/>
- <xsl:for-each select="$interface/header/message/param">
- <xsl:variable name="prefix" select="substring-before(@element,':')"/>
- <soap:header message="tns:{ ../../@name }" part="{ @name }" use="literal" namespace="{ string($info/*[local-name()='definitions']/namespace::*[name()=$prefix])}" required="false"/>
- </xsl:for-each>
- </wsdl:input>
- <wsdl:output>
- <soap:body use="literal"/>
- <xsl:for-each select="$interface/header/message/param">
- <xsl:variable name="prefix" select="substring-before(@element,':')"/>
- <soap:header message="tns:{ ../../@name }" part="{ @name }" use="literal" namespace="{ string($info/*[local-name()='definitions']/namespace::*[name()=$prefix])}" required="false"/>
- </xsl:for-each>
- </wsdl:output>
- <xsl:for-each select="message/fault">
- <wsdl:fault name="{ substring-after(@name, ':') }">
- <soap:fault name="{ substring-after(@name, ':') }" use="literal">
- <xsl:apply-templates select="documentation"/>
- </soap:fault>
- </wsdl:fault>
- </xsl:for-each>
- </wsdl:operation>
- </xsl:for-each>
- </wsdl:binding>
- <wsdl:service name="{ definition }WebService">
- <wsdl:port name="{ definition }Port" binding="tns:{ definition }Binding">
- <soap:address location="{ $server }"/>
- </wsdl:port>
- </wsdl:service>
- </xsl:template>
- <xsl:template match="*" mode="copyroot">
- <xsl:copy>
- <xsl:copy-of select="@*"/>
- <xsl:copy-of select="*"/>
- </xsl:copy>
- </xsl:template>
- </xsl:stylesheet>
|