I am using Saxon 9 on Windows 7/64 in a cygwin bash shell.
I have a chain of templates that process using a mode="import" on each template.
Somewhere near the end of the chain I would like to diverge the processing to a different template for certain cases. These cases are known at the start of the chain, so what I want to do is something like:
Code:
<xs:template match="A" mode="a | b">
<xs:apply-templates select="B" mode="#current"/>
</>
<xs:template match="B" mode="a | b">
<xs:apply-templates select="C" mode="#current"/>
</>
<!-- here I diverge -->
<xs:template match="C" mode="a">
<xs:apply-templates select="D" mode="#current"/>
</>
<xs:template match="C" mode="b">
<xs:apply-templates select="E" mode="#current"/>
</>
I know I have severely butchered the syntax in favour of brevity, but I hope you get the idea.
In reality my chain is much deeper than this. When I start I know if I want the D or the E behavour, so I can start out using the mode a or b and use the same templates up until I get to the end where a or b will select the D or E template path.
My other alternatives are to write parallel templates for a and for b, or to consider refactoring my code to do the processing a different way.