<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/">

<root>
<xsl:for-each select="well/Table">
<parent>
<id>ID=<xsl:value-of select="ID"/></id>
<name>Name=<xsl:value-of select="NAME"/><br/></name>
<xsl:variable name="sid" select="ID"/>
<!--<p><xsl:value-of select="$sid"/></p>-->
<xsl:for-each select="/well/Table1[ID=$sid]">
<child>
<id><xsl:value-of select="ID"/></id>
<lang><xsl:value-of select="LANG"/></lang>
</child>
<br/>
</xsl:for-each>
<br/>
</parent>
</xsl:for-each>
</root> </xsl:template>
</xsl:stylesheet>