0

I am trying to filter out a username for an incoming connection with .xsl file(DataPower appliance). I have 4 scenarios

user@domain.com - needs to stay the way it is.

user@remove.com - need to remove the domain part.

user@domain.com@remove.com - need to remove only the remove part.

user@remove.com.anything - again need to remove this and everything after.

There are 3 variables here. The 'user' can be anything. The domain can be anything. And the .anything after the remove.com, can be anything. @remove.com will ALWAYS be the same. Luckily that is the constant we can use.

Is there a simple if/then statement we can use to do this. We have tried many variations of If, when, contains, and can't seem to get it working. I can paste the code we are currently using if that will help.

Thanks.

czah
  • 49
  • 2
  • 7

2 Answers2

0

A good solution for your problem can be Regex expressions, try "regexp:match(yourExpressionGoesHere)" and then you just have to write the specific regex for each case.

MRodrigues
  • 1,927
  • 1
  • 17
  • 22
0

We figured it out. Sorry to jump the gun, we've been at this a few days.

Here's the code:

    <xsl:template match="@* | node()">
      <xsl:variable name="userid" select="substring-after(/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='Authenticate']/*[local-name()='username'],'@')"/>
<xsl:choose>
<xsl:when test="contains($userid,'remove')">     
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:*deleted*">
            <soapenv:Header />  
            <soapenv:Body>
                <urn:authenticate>
                    <userId0>
                           <xsl:value-of select="substring-before(/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='Authenticate']/*[local-name()='username'],'@remove.com')"/>
                    </userId0> 
                    <credential>
                           <xsl:value-of select="/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='Authenticate']/*[local-name()='password']"/>       
                    </credential>
                </urn:authenticate>
            </soapenv:Body>
        </soapenv:Envelope>
    </xsl:when>
    <xsl:otherwise>
       <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:*deleted*">
            <soapenv:Header />  
            <soapenv:Body>
                <urn:authenticate>
                    <userId0>
                           <xsl:value-of select="/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='Authenticate']/*[local-name()='username']"/>
                    </userId0> 
                    <credential>
                           <xsl:value-of select="/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='Authenticate']/*[local-name()='password']"/>       
                    </credential>
                </urn:authenticate>
            </soapenv:Body>
        </soapenv:Envelope>
</xsl:otherwise> 
</xsl:choose> 
    </xsl:template>
czah
  • 49
  • 2
  • 7