What does this do: <xsl:apply-templates select="." />

S

Soren Kuula

KJ said:
What does this do: <xsl:apply-templates select="." /> ?
Applies the best matching template for the current context node.

Unless inside a for-each, it will cause infinite recursion...

Soren
 
K

KJ

If inside a template, such as:

<xsl:template match="para" mode="note">
<xsl:apply-templates select="." /><br />
</xsl:template>

Then does it only match para's inside notes? Or does it match para's
children also, or what? I didn't write this, only trying to understand
someone else's code.
 
D

Dimitre Novatchev

KJ said:
If inside a template, such as:

<xsl:template match="para" mode="note">
<xsl:apply-templates select="." /><br />
</xsl:template>

Then does it only match para's inside notes?

No, this template will only be selected for processing of a "para" element
if the corresponding xsl:apply-templates had its "mode" attribute set to
"note".

Once selected for processing it delegates this processing to the "normal"
template (without mode specified), that matches a "para".

This code may have been written when the author realised the need for a
special mode of processing "para"s but didn't have time to fully implement
it and as a first step just wrote the moded template as a wrapper of the
normal template.

Or such a template may include the normal processing and also do something
in addition (not shown in the above code) both before or after the normal
processing.
Or does it match para's
children also,

No.

Cheers,
Dimitre Novatchev
 
K

KJ

So the <xsl:apply-templates select="." /> part of the block does the
delegation of processing to the "normal" template (without mode
specified) then?
 
D

Dimitre Novatchev

KJ said:
So the <xsl:apply-templates select="." /> part of the block does the
delegation of processing to the "normal" template (without mode
specified) then?

Yes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,247
Members
46,844
Latest member
JudyGvh32

Latest Threads

Top