Don't think in terms of looping, xslt is not a procedural language.
Write one template rule for messages containing a 1:
<xsl:template match="message[contains(.,'1')]">
<xsl:value-of select="."/>
</xsl:message>
and another rule (that does nothing) for the rest:
<xsl:template match="message"/>
Michael Kay
http://www.saxonica.com/