This questions is simpler to describe by example rather than as text.
With the following XML
<?xml version="1.0" encoding="UTF-8"?>
<tests>
<test>1</test>
<test>2</test>
</tests>
If I run the following XSLT3
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
expand-text="true"
version="3.0">
<xsl:output method="xml" />
<xsl:mode on-no-match="shallow-copy" />
<!--<xsl:mode name="test" on-no-match="shallow-copy"/>-->
<xsl:template match="/">
<mytests>
<xsl:apply-templates/>
<xsl:apply-templates mode="test"/>
</mytests>
</xsl:template>
<xsl:template match="tests" mode="test">
<modetest>
<xsl:apply-templates mode="#current"/>
</modetest>
</xsl:template>
</xsl:stylesheet>
I get following output in Saxon 9
<?xml version="1.0" encoding="UTF-8"?>
<mytests>
<tests>
<test>1</test>
<test>2</test>
</tests>
<modetest>
1
2
</modetest>
</mytests>
You can see that when the mode "test" is being used we do not get the test element being output, only that elements content. There is not template for the element "test" with a mode of "test".
I would have guessed that as there is no match the on-no-match="shallow-copy" would have kicked in from the xsl:mode with no name attribute? My guess was that a no named xsl:mode would apply to all no matches even if a mode was is in effect (unless another xsl:mode is defined with a name that matches the current mode). If you uncomment the xsl:mode name="test" on-no-match="shallow-copy" then everything works as expected (so no workaround required thanks) but this means that in an XSLT with lots and lots of modes in apply-templates, I need to define lots and lots of named xsl:modes just to get the identity template behavior.
Can anyone point out if I am doing something wrong or if this is behaving as per the w3C specification?