You can load the lookups into global variables, outside of any template. Then you can use them within any template. Also it is often easier if your variable names mean something (and you need single quotes around the filenames, as they are string literals).
Code:
<xsl:variable name="firmCodes" select="document('Lookup1.xml
')" />
<xsl:variable name="firmTypes" select="document('Lookup2.xml
')" />
Then I usually start with an identity template:
Code:
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
Then look at what you want to change. In this instance it is the <criteria> element. You want to process all its children, then add two new elements at the end based on the lookup values.
Code:
<xsl:template match="criteria">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:variable name="firm" select="Firm"/>
<xsl:variable name="type" select="Type"/>
<FirmCode><xsl:value-of select="$firmCodes//Info[Firm=$firm]/FirmCode"/></FirmCode>
<FirmTypeFromAttribute><xsl:value-of select="$firmTypes//Firm[@type=$type]"/></FirmTypeFromAttribute>
</xsl:copy>
</xsl:template>
This could be speeded up with use of the <xsl:key> instruction, but assuming your lookup files aren't too large this should work fine.