Search code examples
xmlxsltxsdwsdlmule

Remove extra part in remoteClientAddress string in .xslt in MULE server 3.3.0 CE?


In my configuration.xml in MULE server 3.3.0 CE, I pass MULE_REMOTE_CLIENT_ADDRESS to .xslt file, below I copied my codes :

    <logger 
  message="#[message.inboundProperties['MULE_REMOTE_CLIENT_ADDRESS']]" 
  level="INFO" doc:name="Logger"/>

To pass IP address to XSLT, store it in a variable and pass that.

    <set-variable 
  variableName="remoteClientAddress" 
  value = "#[message.inboundProperties['MULE_REMOTE_CLIENT_ADDRESS']]"/>

Pass it to XSLT as:

<xm:xslt-transformer xsl-file="xsltFileName.xslt">
  <xm:context-property 
    key="remoteClientAddress" 
    value="#[remoteClientAddress]"/>
</xm:xslt-transformer>

In my XSLT, declared a param variable

<xsl:param  name="remoteClientAddress" />

and then use this variable as

<xsl:value-of select="$remoteClientAddress" />

But in configuration.xml file I use this :

<logger message="Remote client address is------> #[remoteClientAddress]" level="INFO" doc:name="Logger"/>

for checking IP-Address, but in my MULE Console I saw this statement : /127.0.0.1:51708 while I need to 127.0.0.1 I don't need / before ip-address and :51708 at the end of my ip-address.

How can I remove these extra parts in Configuration.xml in mule and then just send ip-address to .xslt file ?


Solution

  • I don't know anything about Mule, but you could just do this:

    <xsl:param  name="remoteClientAddress" />
    <xsl:variable name="remoteClientAddressTrimmed"
           select="substring-before(substring-after($remoteClientAddress, '/'), ':')" />
    

    and then later

    <xsl:value-of select="$remoteClientAddressTrimmed" />