Hello,
please try following xsl for your problem....
<?xml version="1.0"?>
<xsl:stylesheet xmlns
sl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="segment">
<P>
Segment matched<xsl:value-of select="@Id"/>
<xsl:for-each select="type">
<xsl:if test=".='Green' and @Id='A01'"><br>
Value of A02 when A01 is Green:</br>
<xsl:for-each select="../type">
<xsl:choose>
<xsl:when test="@Id='A02'">
<xsl:value-of select="."/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</P>
</xsl:template></xsl:stylesheet>
Does this solve your problem?
Regards,