First, I put repeated part of your
test in a separate template and named it "PAX_NUM" (whatever it means
![](https://www.javaranch.com/ubb/biggrin.gif)
) - to prevent code duplication (you would do it anyway at later stages of development
![](https://www.javaranch.com/ubb/smile.gif)
) Next point is more serious: I do not know how exactly you call your two tests, but it looks like you do not follow XML document structure, but first choose all REVENUE elements with NAME value of ACTUAL, then all REVENUE with NAME of 'BUDGET'. From your question "how to diffentiate between nodes" I assume that you want to process XML input how it is. In this case you can have two <xsl:template> element which will match your two cases:
<xsl:template match="REVENUE[./@NAME = 'ACTUAL']">
and
<xsl:template match="REVENUE[./@NAME = 'BUDGET']">
The whole stylesheet:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="REVENUE[./@NAME = 'ACTUAL']">
<xsl:call-template name="PAX_NUM"/>
</xsl:template>
<xsl:template match="REVENUE[./@NAME = 'BUDGET']">
<xsl:call-template name="PAX_NUM"/>
</xsl:template>
<xsl:template name="PAX_NUM">
<xsl:choose>
<xsl:when test="not(string(./PAX_NUM))">-</xsl:when>
<xsl:otherwise><xsl:value-of select="./PAX_NUM"/>
</xsl: otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
The output is:
10
20
Of course, in your case both tests/templates do the same, so there is no real need to differentiate
![](https://www.javaranch.com/ubb/smile.gif)
But you can have different elements inside your templates.
[This message has been edited by Mapraputa Is (edited July 31, 2001).]