Hi,
I've got a node set that's selected by an ugly, gnarly Xpath
expression... let's call that the "outer" node set. Those nodes, in
turn, contain the nodes that I need to transform let's call those
the "inner" node set. Everything else is to be filtered out of my
transformation.
I don't want to have to repeat the hairy Xpath expression in the
template that matches the "inner" nodes, so I used a mode that lets me
match these nodes just by their name. The mode keeps the template from
being applied to nodes that would otherwise match, i.e. nodes outside
the "outer" nodes.
For example (XHTML):
<xsl:template match="really-hair-xpath-expresssion"> <!-- outer -->
.
.
<xsl:apply-templates select="li" mode="process" /> <!-- inner -->
.
.
</xsl:template>
<!-- inner -->
<xsl:template match="li" mode="process">
.
.
</xsl:template>
Once again, the idea here is to avoid having to write the second
template with
match="really-hairy-xpath-expression/li"
I get the feeling that this situation must come up all the time, but...
(a) This is the first time I recall having to solve this problem, and
(b) I haven't seen it mentioned as a typical application in
explanations of moded templates. All that makes me feel like I'm
missing something, or like I've solved this before in some different
way. Is there a "right way" to do this? Is this a normal use for
moded templates?
Thanks,
mark