ina wrote:
> like to do it is to find the company information for each company ID in
> car and type of contract.
Try this. It's not great code, but it should be readable. Making it
better would need more information, particularly about error handling,
handling changes of address etc. It could get to be quite complex.
The XML schema is also less well-designed than it could be. Be generous
with container elements to wrap up related items, be careful with case,
be careful with plurals
<xsl

utput method ="xml" indent="yes" />
<xsl:template match="/">
<cars>
<xsl:for-each select="/Datasource/cars/car">
<!--
You'd be better with a <car> container element here
<car>
-->
<car_name><xsl:value-of select="./car_Short_Name"
/></car_name>
<xsl:for-each select="./car_Contracts">
<xsl:variable name="contract" select="." />
<xsl:variable name="contract-type"
select="$contract/CtoF_Contract/CtoF_Contract_Type/@Type" />
<xsl:variable name="company"
select="/Datasource/Companies/Company [Company_FID =
$contract/CtoF_Contract/Company_FID] " />
<xsl:choose>
<xsl:when test="$contract-type = 'Administrator'" >
<administrator><xsl:value-of
select="$company/Company_Legal_Name/Company_Name" /></administrator>
</xsl:when>
<xsl:when test="$contract-type = 'Firm'" >
<Firm><xsl:value-of select="$company/Company_Legal_Name/Company_Name"
/></Firm>
</xsl:when>
</xsl:choose>
<domicile><xsl:value-of select="$company/Site [@Main='Yes']
/Address/Country" /></domicile>
</xsl:for-each>
<!-- </car> -->
</xsl:for-each>
</cars>
</xsl:template>