Here is a lookup file get the values for Table attributes that match in the actual xml files
&l
It is best to use a key to lookup values. Here is a minimized example:
Given this input XML:
<?xml version="1.0" encoding="UTF-8"?>
<p:transformOutput xmlns:p="http://cfpe/export/objects">
<p:objectSet>
<p:objects>
<p:object>
<p:objectType>FNC</p:objectType>
</p:object>
</p:objects>
</p:objectSet>
</p:transformOutput>
and a second file named templates.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Templates>
<Template>
<Name>FNC</Name>
<Value>-22</Value>
</Template>
</Templates>
the following stylesheet:
XSLT 1.0
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:p="http://cfpe/export/objects"
exclude-result-prefixes="p">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="template" match="Template" use="Name" />
<xsl:template match="/p:transformOutput/p:objectSet">
<objects>
<xsl:for-each select="p:objects/p:object">
<xsl:variable name="objType" select="p:objectType" />
<object type="{$objType}">
<template>
<!-- switch context to the lookup file in order to use key -->
<xsl:for-each select="document('templates.xml')">
<xsl:copy-of select="key('template', $objType)/Value"/>
</xsl:for-each>
</template>
</object>
</xsl:for-each>
</objects>
</xsl:template>
</xsl:stylesheet>
will return:
<?xml version="1.0" encoding="UTF-8"?>
<objects>
<object type="FNC">
<template>
<Value>-22</Value>
</template>
</object>
</objects>
In XSLT 2.0 you'll be able use the lookup file as an argument of the key() function, thus avoiding the need to switch context.