I seem to have problem retrieving the value of a node when the node name is the value of another node in the same document. Let me illustrate.
First the document:
<?xml version="1.0" encoding="UTF-8"?>
<Doc>
<Schools>
<School>
<Id>5489</Id>
<Name>St Thomas</Name>
<Address>High Street, London, England</Address>
</School>
<School>
<Id>7766</Id>
<Name>Anderson Boys School</Name>
<Address>Haymarket, Edinborough</Address>
</School>
</Schools>
<FamilySmith>
<Children>
<Child>
<Name>Thomas</Name>
<School_Id>5489</School_Id>
</Child>
<Child>
<Name>Andrew</Name>
<School_Id>7766</School_Id>
</Child>
</Children>
</FamilySmith>
</Doc>
I simply want to display the following: Thomas goes to St Thomas at High Street, London, England. Andrew goes to Anderson Boys School at Haymarket, Edinborough
Using the folollowing xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/Doc">
<xsl:apply-templates select="FamilySmith"/>
</xsl:template>
<xsl:template match="FamilySmith">
<xsl:for-each select="Children/Child">
<xsl:text>
 </xsl:text>
<xsl:value-of select="Name"/>
<xsl:text> goes to </xsl:text>
<xsl:value-of select="/Doc/Schools/School[Id = School_Id]/Name"/>
<xsl:text> at </xsl:text>
<xsl:value-of select="/Doc/Schools/School[Id = School_Id]/Address"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
But it seems that the expression /Doc/Schools/School[Id = School_Id]... does not work as it returns an empty value each time. The results are given below.
Thomas goes to at Andrew goes to at
Any offers pleaese? Thanks.