kickaha: (Default)
kickaha ([personal profile] kickaha) wrote2008-10-03 04:28 pm

XSLT, you sonofabitch...

I've wasted most of two days now looking for the logical error in an XSLT I whipped up to merge massive data sets for my research. (The naive merge.xslt that bounces around the web as the go-to-tool took literally most of a day to merge the full data run. I thought I could do better.*) After all this time, I finally saw it...

<xslt:template math="@*|node()" mode="m:copy">
    <xslt:copy>
        <xslt:copy-of select="@*" />
        <xslt:apply-templates mode="m:copy" />
    </xslt:copy>
</xslt:template>

Can you spot the error?  No errors reported by xsltproc, it was perfectly happy to consume that tidbit.  Okay, so I gave you a head start, since this was culled out of a 500+ line XSLT.

 
*I did. About 120x faster, more for some specific cases.