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 developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

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 2: Transform for converting standard WSDL to RDF form

 <?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:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:x="http://namespaces.ogbuji.net/articles"
 >
   <xsl:output method='xml' indent='yes'/>
   <!-- template 2.1 -->
   <xsl:template match='wsdl:definitions'>
     <xsl:copy>
       <xsl:apply-templates select='@*'/>
       <xsl:apply-templates select='*'/>
       <rdf:RDF>
         <xsl:apply-templates select='*' mode='convert-to-rdf'/>
       </rdf:RDF>
     </xsl:copy>
   </xsl:template>
   <!-- template 2.2 -->
   <xsl:template match='wsdl:message|wsdl:portType|wsdl:binding|wsdl:service|wsdl:port' mode='convert-to-rdf'>
     <xsl:copy>
       <xsl:attribute name='rdf:ID' namespace='http://www.w3.org/1999/02/22-rdf-syntax-ns#'><xsl:value-of select='@name'/></xsl:attribute>
       <xsl:apply-templates select='@*' mode='convert-to-rdf'/>
       <xsl:apply-templates select='*'/>
       <xsl:apply-templates select='*' mode='convert-to-rdf'/>
     </xsl:copy>
   </xsl:template>
   <!-- template 2.3 -->
   <xsl:template match='wsdl:operation|wsdl:part|soap:*|mime:*|http:*' mode='convert-to-rdf'>
     <xsl:copy>
       <xsl:apply-templates select='@*' mode='convert-to-rdf'/>
       <xsl:apply-templates select='*'/>
       <xsl:apply-templates select='*' mode='convert-to-rdf'/>
     </xsl:copy>
   </xsl:template>
   <!-- template 2.4 -->
   <xsl:template match='wsdl:input|wsdl:output|wsdl:fault' mode='convert-to-rdf'>
     <xsl:copy>
       <xsl:attribute name='rdf:resource' namespace='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
         <xsl:value-of select="substring-after(@message, ':')"/>
       </xsl:attribute>
       <xsl:apply-templates select="@*[not(name(.)='message')]" mode='convert-to-rdf'/>
       <xsl:apply-templates select='*'/>
       <xsl:apply-templates select='*' mode='convert-to-rdf'/>
     </xsl:copy>
   </xsl:template>
   <!-- template 2.4 -->
   <xsl:template match='wsdl:message|wsdl:portType|wsdl:binding|wsdl:service|wsdl:operation|wsdl:port|wsdl:part|wsdl:input|wsdl:output|wsdl:fault|soap:*'/>
   <!-- Lookup table for WSDL namespaces -->
   <xsl:key name='ns-to-prefix' match='x:ns-to-prefix' use='@uri'/>
   <x:ns-to-prefix uri='http://schemas.xmlsoap.org/wsdl/' prefix='wsdl'/>
   <x:ns-to-prefix uri='http://schemas.xmlsoap.org/wsdl/soap/' prefix='soap'/>
   <x:ns-to-prefix uri='http://schemas.xmlsoap.org/wsdl/mime/' prefix='mime'/>
   <x:ns-to-prefix uri='http://schemas.xmlsoap.org/wsdl/http/' prefix='http'/>
   <xsl:variable name='load-lookup-table' select="document('')"/>
   <!-- template 2.5 -->
   <xsl:template match='@*' mode='convert-to-rdf'>
     <!-- attach the prefix that goes with the element's namespace -->
     <xsl:attribute name="{concat(key('ns-to-prefix', namespace-uri(..))/@prefix, ':', name(.))}"
                    namespace='{namespace-uri(.)}'>
       <xsl:value-of select='.'/>
     </xsl:attribute>
   </xsl:template>
   <!-- template 2.6 -->
   <xsl:template match='*' mode='convert-to-rdf'/>
   <!-- template 2.7 -->
   <xsl:template match='*|@*'>
     <xsl:copy>
       <xsl:apply-templates select='@*|node()'/>
     </xsl:copy>
   </xsl:template>
 </xsl:stylesheet>
 
 

Return to article