Author: jonathan
Date: Fri Jan 18 16:51:32 2008
New Revision: 12495
Log:
Added localhost-endpoints parameter.
Modified:
trunk/commons/dynamic-codegen/src/jsstub.xslt
Modified: trunk/commons/dynamic-codegen/src/jsstub.xslt
==============================================================================
--- trunk/commons/dynamic-codegen/src/jsstub.xslt (original)
+++ trunk/commons/dynamic-codegen/src/jsstub.xslt Fri Jan 18 16:51:32 2008
@@ -5,6 +5,7 @@
<xsl:param name="service" select="services/service[1]/@name"/>
<xsl:param name="e4x" select="false()"/>
+ <xsl:param name="localhost-endpoints" select="false()"/>
<xsl:template match="/">
<xsl:apply-templates select="services/[EMAIL PROTECTED]"/>
@@ -173,7 +174,7 @@
<xsl:sort select="@address" order="ascending"/>
"<xsl:value-of select="@endpoint"/>": {
"type" : "<xsl:value-of select="@type"/>",
- "address" : "<xsl:value-of select="@address"/>"<xsl:if
test="operations/operation/binding-details/@wsawaction">,
+ "address" : "<xsl:call-template
name="localnameify-url"><xsl:with-param name="url"
select="@address"/></xsl:call-template>"<xsl:if
test="operations/operation/binding-details/@wsawaction">,
"action" : {<xsl:for-each
select="operations/operation[binding-details/@wsawaction]">
"<xsl:value-of select="@name"/>" : "<xsl:value-of
select="binding-details/@wsawaction"/>"<xsl:if test="position() <
last()">,</xsl:if>
</xsl:for-each>
@@ -879,9 +880,31 @@
<xsl:text> */</xsl:text>
</xsl:template>
- <xsl:template name="xml-name-to-javascript-name">
- <xsl:param name="name"/>
- <xsl:value-of select="translate($name,'.-','__')"/>
- </xsl:template>
+<xsl:template name="xml-name-to-javascript-name">
+ <xsl:param name="name"/>
+ <xsl:value-of select="translate($name,'.-','__')"/>
+</xsl:template>
+
+<xsl:template name="localnameify-url">
+ <xsl:param name="url"/>
+ <xsl:choose>
+ <xsl:when test="$localhost-endpoints">
+ <xsl:variable name="scheme" select="substring-before($url,
'://')"/>
+ <xsl:value-of select="$scheme"/>
+ <xsl:text>://localhost</xsl:text>
+ <xsl:variable name="remainder" select="substring-after($url,
concat($scheme,'://'))"/>
+ <xsl:variable name="domain"
select="substring-before($remainder,'/')"/>
+ <xsl:if test="contains($domain,':')">
+ <xsl:text>:</xsl:text>
+ <xsl:value-of select="substring-after($domain, ':')"/>
+ </xsl:if>
+ <xsl:text>/</xsl:text>
+ <xsl:value-of select="substring-after($remainder, '/')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$url"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
</xsl:stylesheet>
_______________________________________________
Commons-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/commons-dev