Well basically given your XSLT you have the same match patterns twice, you have xsl:template match="product"
and xsl:template match="product[@id = 'p2']"
and then you have xsl:template match="product|product[@id = 'p2']"
again. That way there are certainly ambiguous matches for all your product
input elements. So I agree with you, with a stylesheet that has the same match pattern twice on different templates, you will get that error or warning of ambiguity. However the processor can choose to only emit a warning and to take the last of the templates. That is what Saxon 9 does for instance, it says something like
Recoverable error
XTRE0540: Ambiguous rule match for /products/product[1]
Matches both "element(Q{}product)" on line 14 of
file:/C:/Users/Martin%20Honnen/Documents/xslt/test2014012101.xsl
and "element(Q{}product)" on line 8 of
file:/C:/Users/Martin%20Honnen/Documents/xslt/test2014012101.xsl
Recoverable error
XTRE0540: Ambiguous rule match for /products/product[2]
Matches both "product|product[@id = 'p2']" on line 14 of
file:/C:/Users/Martin%20Honnen/Documents/xslt/test2014012101.xsl
and "product[@id = 'p2']" on line 11 of
file:/C:/Users/Martin%20Honnen/Documents/xslt/test2014012101.xsl
Recoverable error
XTRE0540: Ambiguous rule match for /products/product[3]
Matches both "element(Q{}product)" on line 14 of
file:/C:/Users/Martin%20Honnen/Documents/xslt/test2014012101.xsl
and "element(Q{}product)" on line 8 of
file:/C:/Users/Martin%20Honnen/Documents/xslt/test2014012101.xsl
but then writes an output of
<PRODUCTS>
<!-- Delta -->
<PRODUCT id="p1" price="3250" stock="4"/>
<!-- Golf -->
<PRODUCT id="p2" price="1250" stock="5"/>
<!-- Alpha -->
<PRODUCT id="p3" price="1200" stock="19"/>
</PRODUCTS>