xsl-list
[Top] [All Lists]

Re: How to produce a record of changes made in an identity transform?

2004-07-28 04:24:36

This is really like a table of contents, so the canonical way of
proceeding is to process the document twice, with two modes
so

<xsl:template match="/">
 <xsl:apply-templates/>
<xsl:result-document ....>
 <xsl:apply-templates mode="log"/>
</xsl:result document>
</xsl:template>

You then just duplicate every 
<xsl:template match="something">
that's doing something otherthan an identity and have
<xsl:template match="something" mode=log">
 I did something
</xsl:template>

If reprocessing the document twice and duplicating the templates doesn't
feel right then an alternative plan (which isn't really following the
one-true-path to functional programming purity is to stick an 
<xsl:message>
I did something
</xsl:message>
into any template that does anything, then use your command line or API
to redirect the xsl:message output to your log file.

Note however that the first way is guaranteed to produce the log in a
logical order, the second way will most likely produce the log in the
order that the system actually evaluated the templates, which if you
have some (perhaps mythical) highly parralelised and optimised xslt
engine mightbe in any order at all.

David


________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________