Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

WSDL processing with XSLT

First steps for Web service description processing

Return to article


Listing 1: Simple transform to extract summary of services

 <?xml version="1.0"?>
 <xsl:stylesheet
   version='1.0'
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:es="http://www.snowboard-info.com/EndorsementSearch.wsdl"
   xmlns:esxsd="http://schemas.snowboard-info.com/EndorsementSearch.xsd"
   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
   xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
   xmlns:x="http://namespaces.ogbuji.net/articles"
 >
   <xsl:output method='html'/>
   <!-- template 1.1 -->
   <xsl:template match='/'>
     <HTML>
     <HEAD>
       <TITLE>Service summary: <xsl:value-of select='wsdl:definitions/@name'/></TITLE>
       <META HTTP-EQUIV="content-type" content="text/html" charset="UTF-8"/>
     </HEAD>
     <BODY STYLE="background: #ffffff">
       <H1>Service summary: <xsl:value-of select='wsdl:definitions/@name'/></H1>
       <HR/>
       <xsl:apply-templates select="wsdl:definitions/wsdl:service"/>
     </BODY>
     </HTML>
   </xsl:template>
   <!-- Lookup table 1.1: messages -->
   <xsl:key name='message' match="wsdl:definitions/wsdl:message" use='@name'/>
   <!-- Lookup table 1.2: portTypes -->
   <xsl:key name='portType' match="wsdl:definitions/wsdl:portType" use='@name'/>
   <!-- Lookup table 1.3: bindings -->
   <xsl:key name='binding' match="wsdl:definitions/wsdl:binding" use='@name'/>
   <!-- Lookup table 1.4: services -->
   <xsl:key name='service' match="wsdl:definitions/wsdl:service" use='@name'/>
   <!-- Lookup table 1.5: the transport for each binding -->
   <xsl:key name='bindtrans'
     match="wsdl:definitions/wsdl:binding/*[local-name()='binding']"
     use='../@name'/>
   <!-- template 1.2 -->
   <xsl:template match='wsdl:service'>
     <TABLE>
       <THEAD>Service: <xsl:value-of select='@name'/></THEAD>
       <TBODY>
       <TR>
         <TD COLSPAN='3' STYLE="background: #ccffff">
           <I><xsl:value-of select='wsdl:documentation'/></I>
         </TD>
       </TR>
       <xsl:for-each select='wsdl:port'>
         <xsl:variable name='binding-local-name'
           select="substring-after(@binding, ':')"/>
         <xsl:variable name='binding-uri'
           select="namespace-uri(key('bindtrans', $binding-local-name))"/>
         <TR>
           <TD>Port: </TD>
           <TD STYLE="background: #ffccff"><xsl:value-of select="*[local-name()='address']/@location"/></TD>
           <TD STYLE="background: #ff66ff">
             <xsl:value-of select="key('ns-to-binding', $binding-uri)/@binding"/>
           </TD>
         </TR>
       </xsl:for-each>
     </TBODY>
     </TABLE>
   </xsl:template>
   <!-- Lookup table 1.6: WSDL binding types -->
   <xsl:key name='ns-to-binding' match='x:ns-to-binding' use='@uri'/>
   <x:ns-to-binding uri='http://schemas.xmlsoap.org/wsdl/soap/' binding='SOAP'/>
   <x:ns-to-binding uri='http://schemas.xmlsoap.org/wsdl/mime/' binding='MIME'/>
   <x:ns-to-binding uri='http://schemas.xmlsoap.org/wsdl/http/' binding='HTTP'/>
   <xsl:variable name='load-lookup-table' select="document('')"/>
 </xsl:stylesheet>
 

Return to article