Use this single XPath 1.0 expression:
concat(/Header/info/data/Body/basketAB
[contains('|A|B|', concat('|', $typology, '|'))]/date
| /Header/info/data/Body/basketCDE
[contains('|C|D|E|', concat('|', $typology, '|'))]/date,
substring('CheckPath',
1 div not(contains('|A|B|C|D|E|', concat('|', $typology, '|'))))
)
Verification using XSLT 1.0:
Given this source XML document:
<Header>
<info>
<data>
<Body>
<basketAB>
<date>date1</date>
</basketAB>
<basketCDE>
<date>date2</date>
</basketCDE>
</Body>
</data>
</info>
</Header>
this XSLT transformation evaluates the above XPath expression and outputs the result of this evaluation:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:variable name="typology" select="'A'"/>
<xsl:template match="/">
<xsl:variable name="date" select=
"concat(/Header/info/data/Body/basketAB[contains('|A|B|', concat('|', $typology, '|'))]/date
| /Header/info/data/Body/basketCDE[contains('|C|D|E|', concat('|', $typology, '|'))]/date,
substring('CheckPath', 1 div not(contains('|A|B|C|D|E|', concat('|', $typology, '|'))))
)"/>
<xsl:value-of select="$date"/>
</xsl:template>
</xsl:stylesheet>
Run the transformation several times, each time specifying a different value for the variable $typology:
The wanted results are produced in all cases:
'A' --> date1
'B' --> date1
'C' --> date2
'D' --> date2
'E' --> date2
'X' --> CheckPath