[Home] [By Thread] [By Date] [Recent Entries]
Nicholas Orr wrote:
On 07/02/2007, at 4:07 PM, G. Ken Holman wrote: Depending on your needs, it may be better suited to use template matching instead of for-each. For instance, the above for-each can be written in separate templates like this (first one is your initial template): <xsl:template match="/"> <xsl:apply-templates select="ExportEntries[../Restore/@state='True']" /> </xsl:template> <xsl:template match="ExportEntries"> ... do something on ExportEntry level .... <xsl:apply-templates select="ExportEntry/Field" /> </xsl:template> <xsl:template match="Field">
.... do something on field level ....
... this is the same as the core of your for-each ...
</xsl:template>This is also referred to as the difference between the push and pull model, where the for-each is the push model (you push the elements through, meaning, you decide what to do and how) and the template model is the pull model (you let the processor do the work for you, it pulls each node, through a chain of templates, you only declare the rules; hence the term: declarative programming). -- Abel
|

Cart



