Yes, there are three default
template rules.
1. The first default rule applies to element nodes and the root
node:
<xsl:template
match="*|/">
<xsl:apply-templates/>
</xsl:template>
The purpose of this rule is to ensure that all elements are
recursively processed even if they aren't reached by following
the explicit rules.
2. The second default rule applies to text nodes and attributes:
<xsl:template
match="text()|@*">
<xsl:value-of
select="."/>
</xsl:template>
This rule matches all text and attribute nodes and outputs the
value of the node.
3. The default rule for processing instructions and comments:
<xsl:template match="processing-instruction()|comment()"/>
It simply says to do nothing; that is, drop the processing
instructions and comments from the output as if they didn't
exist.
I don't think we can define the templates
dynamically, because XSLT is a declarative language. There is nothing we can do at
runtime.
|