[Home] [By Thread] [By Date] [Recent Entries]

Subject: Re: efficiently detecting size of input document?
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Thu, 14 Aug 2008 10:43:56 +0100
> For (2), the challenge would be how to process the first [certain
> amount] of the document and no more, again without inefficiently
> counting nodes.

Do a sibling-recursion identity transform:

    <xsl:template match="node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()[1]"/>
        </xsl:copy>
        <xsl:apply-templates select="following-sibling::node()[1]"/>
    </xsl:template>

    <xsl:template match="@*">
        <xsl:copy/>
    </xsl:template>

Just add a parameter which maintains the count...


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member