Subject: Re: [xsl] How many passes through the document From: Michael Kay <mike@xxxxxxxxxxxx> Date: Sun, 23 Sep 2012 08:59:58 +0100 |
Michael Kay Saxonica
Of course if I had written it like this with the variable local instead of global I wouldn't be asking the question.
So I guess the question is whether the global version entails an extra pass over the data or any other performance penalty.
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" exclude-result-prefixes="xs"> <xsl:output method="text"/> <xsl:key name="elems" match="*" use="name()"/> <xsl:key name="counts" match="*" use="count(key('elems',name()))"/>
<xsl:template match="/"> <xsl:variable name="all" as="xs:integer+"> <xsl:apply-templates select="*"/> </xsl:variable> <xsl:sequence select="sum(key('counts',max($all))/count(@*))"/> </xsl:template>
<xsl:template match="*"> <xsl:sequence select="count(key('elems',name()))"/> <xsl:apply-templates/> </xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How many passes through t, Liam R E Quin | Thread | Re: [xsl] How many passes through t, Ihe Onwuka |
Re: [xsl] How many passes through t, Liam R E Quin | Date | Re: [xsl] How many passes through t, Ihe Onwuka |
Month |