It's a grouping problem, and like all grouping problems it's easy in XSLT 2.0 and tricky in XSLT 1.0. You don't say which you are using.
You also don't explain your requirements very well. If the only grouping you need to do is to group the fields whose names start with SMM, then that's fairly easy: just do something like this:
Code:
<xsl:apply-templates select="searchExpression[not(starts-with(ifw2:fieldName, 'SMM'))]"/>
<ocis:SMMData>
<xsl:apply-templates select="searchExpression[starts-with(ifw2:fieldName, 'SMM')]"/>
</ocis:SMMData>
<xsl:template match="searchExpression[starts-with(ifw2:fieldName, 'Sort')]">
<ocis:sortCD><xsl:value-of select="ifw2:fieldData"/></ocis:sortCD>
</xsl:template>
etc.
Note that splitting the code into template rules like this will make it much more understandable and maintainable than a monilithic xsl:for-each with lots of conditionals.