I'm trying to understand to listing 18 of this page example. The listing looks like this:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href="wsdl-util.xsl"/> <xsl:strip-space elements="*"/> <xsl:output method="text"/> <!-- just process the services --> <xsl:template match="wsdl:definitions"> <xsl:apply-templates select="wsdl:service"/> </xsl:template> <!-- dump out some information for each service --> <xsl:template match="wsdl:service"> <xsl:text>service: </xsl:text> <xsl:value-of select="@name"/> <xsl:text> </xsl:text> <xsl:apply-templates select="wsdl:port"/> </xsl:template> <!-- follow the linkages from the wsdl:port through the wsdl:binding, back to the wsdl:portType and its wsdl:operations --> <xsl:template match="wsdl:port"> <!-- key for looking up the wsdl:binding --> <xsl:variable name="binding-key"> <xsl:apply-templates select="." mode="binding-key"/> </xsl:variable> <xsl:for-each select="key('binding',$binding-key)"> <!-- key for looking up the wsdl:portType --> <xsl:variable name="porttype-key"> <xsl:apply-templates select="." mode="porttype-key"/> </xsl:variable> <!-- process each operation in the wsdl:portType --> <xsl:for-each select="key('porttype',$porttype-key)/wsdl:operation"> <xsl:apply-templates select="."/> </xsl:for-each> </xsl:for-each> </xsl:template> <!-- generate a Java-like method signature for each operation --> <xsl:template match="wsdl:portType/wsdl:operation"> <xsl:text> </xsl:text> <!-- return type --> <xsl:for-each select="wsdl:output"> <!-- get the correct value for the message name key --> <xsl:variable name="output-message-key"> <xsl:apply-templates select="." mode="message-key"/> </xsl:variable> <!-- output the type of the first part of the message --> <xsl:for-each select="key('message',$output-message-key)/wsdl:part[1]"> <xsl:value-of select="@type"/> </xsl:for-each> </xsl:for-each> <xsl:if test="not(wsdl:output)"> <xsl:text>void</xsl:text> </xsl:if> <!-- method name --> <xsl:text> </xsl:text> <xsl:value-of select="@name"/> <!-- arguments --> <xsl:text>(</xsl:text> <xsl:for-each select="wsdl:input"> <!-- get the correct value for the message name key --> <xsl:variable name="input-message-key"> <xsl:apply-templates select="." mode="message-key"/> </xsl:variable> <!-- output the type of the type and name of each part of the message --> <xsl:for-each select="key('message',$input-message-key)/wsdl:part"> <xsl:value-of select="@type"/> <xsl:text> </xsl:text> <xsl:value-of select="@name"/> <xsl:if test="not(last())"> <xsl:text>, </xsl:text> </xsl:if> </xsl:for-each> </xsl:for-each> <xsl:text>)</xsl:text> <!-- exceptions --> <xsl:if test="wsdl:fault"> <xsl:text> throws </xsl:text> <xsl:for-each select="wsdl:fault"> <!-- get the correct value for the message name key --> <xsl:variable name="fault-message-key"> <xsl:apply-templates select="." mode="message-key"/> </xsl:variable> <xsl:for-each select="key('message',$fault-message-key)"> <xsl:value-of select="@name"/> </xsl:for-each> <xsl:if test="not(last())"> <xsl:text>, </xsl:text> </xsl:if> </xsl:for-each> </xsl:if> <xsl:text>; </xsl:text> </xsl:template> </xsl:stylesheet> out of which they have written the code like this:
<xsl:template match="wsdl:port"> <!-- key for looking up the wsdl:binding --> <xsl:variable name="binding-key"> <xsl:apply-templates select="." mode="binding-key"/> </xsl:variable> <xsl:for-each select="key('binding',$binding-key)"> <!-- key for looking up the wsdl:portType --> <xsl:variable name="porttype-key"> <xsl:apply-templates select="." mode="porttype-key"/> </xsl:variable> <!-- process each operation in the wsdl:portType --> <xsl:for-each select="key('porttype',$porttype-key)/wsdl:operation"> <xsl:apply-templates select="."/> </xsl:for-each> </xsl:for-each> </xsl:template> I could able to sense that the variable binding-key will be equal to the binding value of the WSDL that is processed, which might be like this ( for the given example ):
binding-key : http://tempuri.org/test binding with that in place, I have few questions:
- What does
key()does with the$binding-keywhose value ishttp://tempuri.org/test binding? - And what does
modemeans in theapply-templates
No comments:
Post a Comment