Instead of
choose
when c1
variable x select=1
otherwise
variable x select=2
you can in most cases do
variable x
choose
when c1 1
otherwise 2
The exception (which unfortunately applies here) is that the resulting variable is always a result-tree-fragment, which means you can't use this technique to select existing nodes.
When the variable is a node-set, you can do:
xsl:for-each select="EXP1[C1] | EXP2[not(C1)]"
that is, process the nodes selected by EXP1 if C1 is true, otherwise process the nodes selected by EXP2.
Looking at your specific conditions, you could reduce this to:
<xsl:for-each select="
//customfield[@name='LHSMenu']/sections/rwplistitem[@lvl='1']/sections/rwplistitem
|
/rwpdoc[not(//customfield[@name='LHSMenu'])]/rwplist[@name='stdmenu']/rwplistitem[@lvl='2']" ">...
In XSLT 2.0, of course, this all becomes vastly easier. For example, you could declare the variable like this:
<xsl:variable name="menulisting" select="
if (//customfield[@name='LHSMenu'])
then //customfield[@name='LHSMenu']/sections/rwplistitem[@lvl='1']/sections/rwplistitem
else /rwpdoc/rwplist[@name='stdmenu']/rwplistitem[@lvl='2']"/>
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference