xsl-list
[Top] [All Lists]

[xsl] Recursive Processor to find Type of complex type for WSDL file

2007-03-13 17:36:20
Hi
I need help in recursive loop to find out till I reach primitive data
"TYPE" of request response parts.

For example of Address and Phone ,I need to do recursive till it yield
to primitive types of the type.

This is my XSLT  and WSDL file and for the same are
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
<html>
<head>
<style type="text/css">
th { background: #F6F6F6; }
td { background: #CECECE; }
</style>
 <title>WSDL Analyzer</title>
</head>
<body>

<table border="1" cellspacing="0" cellpadding="2" align="center"
bodercolor="blue" width="100%">
<tr>
 <th>
  <xsl:value-of select="//*[local-name()='service']/@name"/>
 </th>
   <th>
  Operations
 </th>
     <th>
  Request/Response
 </th>
       <th>
  Complex Types
 </th>
</tr>
<tr>
 <td valign="top"  width="25%">Endpoint: <i>
  <xsl:value-of
select="//*[local-name()='service']/*[local-name()='port']/*[local-name()='address']/@location"/>
  </i>
  <br/>Description: <i>
  <xsl:value-of
select="//*[local-name()='service']/*[local-name()='documentation']"/>
  </i>
 </td>
 <td valign="top"  width="25%"> <xsl:apply-templates
select="//*[local-name()='portType']"/> </td>
<td valign="top" width="25%">
 <xsl:for-each
select="//*[local-name()='portType']/*[local-name()='operation']">
<table border="1" cellspacing="0" cellpadding="2" align="center"
bodercolor="blue" width="100%">
 <tr>
  <th>
   <xsl:value-of select="@name"/>
  </th>
 </tr>
 <tr>
  <td>
   <i>
    <u>Request:</u>
   </i>
   <br/>
   <xsl:call-template name="request">
    <xsl:with-param name="input" select="./*[local-name()='input']/@message"/>

   </xsl:call-template>
   <i>
    <u>Response:</u>
   </i>
   <br/>
   <xsl:call-template name="response">
    <xsl:with-param name="output"
select="./*[local-name()='output']/@message"/>
   </xsl:call-template>

  </td>
 </tr>
</table>
</xsl:for-each>
 </td>
 <td valign="top"  width="25%">
  <xsl:call-template name="complex">
  </xsl:call-template>
  </td>
 </tr>
  </table>
</body>
</html>
</xsl:template>
<xsl:template match="//*[local-name()='portType']">
<xsl:for-each select="./*[local-name()='operation']">
 <xsl:value-of select="@name"/>
 <br/>
</xsl:for-each>
</xsl:template>
<xsl:template name="request">
        <xsl:param name="input"/>
        <xsl:for-each select="//*[local-name()='message'][contains($input,
@name)]/*[local-name()='part']">
                <xsl:value-of select="@name"/>
                <xsl:variable name="element" select="@name" />
                <xsl:text> : </xsl:text>
                <xsl:value-of select="$element"/>
                <br/>
                
                
                <xsl:for-each select="//*[local-name()='element'][contains($element, 
@name)]">
                &#8595;&#13;&#8594;<xsl:value-of select="@name"/>
                <xsl:text> : </xsl:text>
                <xsl:value-of select="substring-after(@type,':')"/>
                <br/>
        </xsl:for-each>
        
        </xsl:for-each>
        
        
        
</xsl:template>

<xsl:template name="response">

<xsl:param name="output"/>
<!-- <xsl:for-each
select="//*[local-name()='message'][contains($output,
@name)]/*[local-name()='part']">
                <xsl:value-of select="@name"/>
                <xsl:text> : </xsl:text>
                <xsl:value-of select="@type"/>
                <br/>
</xsl:for-each>-->
        <xsl:for-each select="//*[local-name()='message'][contains($output,
@name)]/*[local-name()='part']">
                <xsl:value-of select="@name"/>
                <xsl:variable name="element" select="@name" />
                <xsl:text> : </xsl:text>
                <xsl:value-of select="$element"/>
                <br/>
                
                
                <xsl:for-each select="//*[local-name()='element'][contains($element, 
@name)]">
                &#8595;             &#13;&#8594;<xsl:value-of select="@name"/>
                <xsl:text> : </xsl:text>
                <xsl:value-of select="substring-after(@type,':')"/>
                <br/>
        </xsl:for-each>
        
        </xsl:for-each>
        

</xsl:template>

<xsl:template name="complex">
<xsl:for-each select="//*[local-name()='complexType']"><xsl:variable
name="struct_name" select="@name" />
<xsl:value-of select="$struct_name" /><br/>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

WSDL FILE:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://server.mydomain.com";
xmlns:impl="http://server.mydomain.com";
xmlns:java="http://schemas.xmlsoap.org/wsdl/java/";
xmlns:intf="http://server.mydomain.com";
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/";
xmlns:apachesoap="http://xml.apache.org/xml-soap";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:tns2="http://vo.provider.esp.ets.ist.mydomain.com";
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
xmlns:format="http://schemas.xmlsoap.org/wsdl/formatbinding/";>
 <wsdl:types>
   <schema elementFormDefault="qualified"
targetNamespace="http://server.mydomain.com";
xmlns="http://www.w3.org/2001/XMLSchema";>
  <element name="name" type="xsd:string"/>
  <element name="getAddressFromNameReturn" type="tns2:Address"/>
  <element name="name1" type="xsd:string"/>
  <element name="address" type="tns2:Address"/>
  <element name="firstName" type="xsd:string"/>
  <element name="lastName" type="xsd:string"/>
  <element name="address1" type="tns2:Address"/>
 </schema>
   <schema elementFormDefault="qualified"
targetNamespace="http://server.mydomain.com";
xmlns="http://www.w3.org/2001/XMLSchema";>
  <complexType name="Phone">
   <sequence>
    <element name="areaCode" type="xsd:int"/>
    <element name="exchange" nillable="true" type="xsd:string"/>
    <element name="number" nillable="true" type="xsd:string"/>
   </sequence>
  </complexType>
  <complexType name="Address">
   <sequence>
    <element name="city" nillable="true" type="xsd:string"/>
    <element name="phoneNumber" nillable="true" type="tns2:Phone"/>
    <element name="state" nillable="true" type="xsd:string"/>
    <element name="streetName" nillable="true" type="xsd:string"/>
    <element name="streetNum" type="xsd:int"/>
    <element name="zip" type="xsd:int"/>
   </sequence>
  </complexType>
 </schema>
 </wsdl:types>
 <wsdl:message name="getAddressFromNameResponse">
   <wsdl:part name="getAddressFromNameReturn"
element="impl:getAddressFromNameReturn"/>
 </wsdl:message>
 <wsdl:message name="addEntryResponse">
 </wsdl:message>
 <wsdl:message name="getAddressFromNameRequest">
   <wsdl:part name="name" element="impl:name"/>
 </wsdl:message>
 <wsdl:message name="addEntryRequest">
   <wsdl:part name="name" element="impl:name1"/>
   <wsdl:part name="address" element="impl:address"/>
 </wsdl:message>
 <wsdl:message name="addEntryRequest1">
   <wsdl:part name="firstName" element="impl:firstName"/>
   <wsdl:part name="lastName" element="impl:lastName"/>
   <wsdl:part name="address" element="impl:address1"/>
  <wsdl:part name="address" element="impl:address1"/>
 </wsdl:message>
 <wsdl:message name="addEntryResponse1">
 </wsdl:message>
 <wsdl:portType name="AddressBook">
   <wsdl:operation name="getAddressFromName" parameterOrder="name">
     <wsdl:input name="getAddressFromNameRequest"
message="impl:getAddressFromNameRequest"/>
     <wsdl:output name="getAddressFromNameResponse"
message="impl:getAddressFromNameResponse"/>
   </wsdl:operation>
   <wsdl:operation name="addEntry" parameterOrder="name address">
     <wsdl:input name="addEntryRequest" message="impl:addEntryRequest"/>
     <wsdl:output name="addEntryResponse" message="impl:addEntryResponse"/>
   </wsdl:operation>
   <wsdl:operation name="addEntry" parameterOrder="firstName lastName address">
     <wsdl:input name="addEntryRequest1" message="impl:addEntryRequest1"/>
     <wsdl:output name="addEntryResponse1" message="impl:addEntryResponse1"/>
   </wsdl:operation>
 </wsdl:portType>
 <wsdl:binding name="AddressBookServiceSoapBindingJava"
type="impl:AddressBook">
     <java:binding/>
        <format:typeMapping style="Java" encoding="Java">
           <format:typeMap typeName="impl:getAddressFromNameReturn"
formatType="com.mydomain.ist.ets.esp.provider.vo.Address"/>
           <format:typeMap typeName="impl:name" formatType="java.lang.String"/>
           <format:typeMap typeName="impl:address"
formatType="com.mydomain.ist.ets.esp.provider.vo.Address"/>
           <format:typeMap typeName="impl:name1"
formatType="java.lang.String"/>
           <format:typeMap typeName="impl:firstName"
formatType="java.lang.String"/>
           <format:typeMap typeName="impl:address1"
formatType="com.mydomain.ist.ets.esp.provider.vo.Address"/>
           <format:typeMap typeName="impl:lastName"
formatType="java.lang.String"/>
        </format:typeMapping>
   <wsdl:operation name="getAddressFromName">
     <java:operation methodName="getAddressFromName"
methodType="Instance" parameterOrder="name"
returnPart="getAddressFromNameReturn"/>
     <wsdl:input name="getAddressFromNameRequest">
     </wsdl:input>
     <wsdl:output name="getAddressFromNameResponse">
     </wsdl:output>
   </wsdl:operation>
   <wsdl:operation name="addEntry">
     <java:operation methodName="addEntry" methodType="Instance"
parameterOrder="name address"/>
     <wsdl:input name="addEntryRequest">
     </wsdl:input>
     <wsdl:output name="addEntryResponse">
     </wsdl:output>
   </wsdl:operation>
   <wsdl:operation name="addEntry">
     <java:operation methodName="addEntry" methodType="Instance"
parameterOrder="firstName lastName address"/>
     <wsdl:input name="addEntryRequest1">
     </wsdl:input>
     <wsdl:output name="addEntryResponse1">
     </wsdl:output>
   </wsdl:operation>
 </wsdl:binding>
 <wsdl:binding name="AddressBookServiceSoapBinding" type="impl:AddressBook">
   <wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
   <wsdl:operation name="getAddressFromName">
     <wsdlsoap:operation soapAction=""/>
     <wsdl:input name="getAddressFromNameRequest">
       <wsdlsoap:body use="literal"/>
     </wsdl:input>
     <wsdl:output name="getAddressFromNameResponse">
       <wsdlsoap:body use="literal"/>
     </wsdl:output>
   </wsdl:operation>
   <wsdl:operation name="addEntry">
     <wsdlsoap:operation soapAction=""/>
     <wsdl:input name="addEntryRequest">
       <wsdlsoap:body use="literal"/>
     </wsdl:input>
     <wsdl:output name="addEntryResponse">
       <wsdlsoap:body use="literal"/>
     </wsdl:output>
   </wsdl:operation>
   <wsdl:operation name="addEntry">
     <wsdlsoap:operation soapAction=""/>
     <wsdl:input name="addEntryRequest1">
       <wsdlsoap:body use="literal"/>
     </wsdl:input>
     <wsdl:output name="addEntryResponse1">
       <wsdlsoap:body use="literal"/>
     </wsdl:output>
   </wsdl:operation>
 </wsdl:binding>
 <wsdl:service name="AddressBookService">
   <wsdl:port name="AddressBookService"
binding="impl:AddressBookServiceSoapBinding">
     <wsdlsoap:address
location="http://server.mydomain.com:8080/providers/services/AddressBookService"/>
   </wsdl:port>
   <wsdl:port name="AddressBookServiceJava"
binding="impl:AddressBookServiceSoapBindingJava">
     <java:address
className="com.mydomain.ist.ets.esp.provider.service.AddressBook"/>
   </wsdl:port>
 </wsdl:service>
</wsdl:definitions>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--