Subject: RE: [xsl] Re: Re: Unbounded element grouping/concatenation From: "Gupta, Raman K [CI]" <raman.k.gupta@xxxxxxxxxxxxx> Date: Thu, 11 Dec 2003 10:52:23 -0500 |
> > Dimitre, could you help me with a DVC algorithm for what I'm trying > > to do? I'm not sure how to apply it to this problem. > > I don't have a good idea of what exactly recursive algorithm > you have to > solve this problem. > > It seems to me that such a recursive algorithm would process > the immediate > following while it is of type="continuation". The recursive algorithm I wish I could use is exactly as you stated. Something like the following (not tested, might be typos) <xsl:template match="records"> <xsl:apply-templates select="record[@type = 'normal']"/> </xsl:template> <xsl:template match="record[@type = 'normal']"> <record> <xsl:copy-of select="*" /> <xsl:if test="following-sibling::record[1][@type='continuation']"> <xsl:apply-templates select=following-sibling::record[1]"/> </xsl:if> </record> </xsl:template> <xsl:template match="record[@type = 'continuation']"> <xsl:copy-of select="*" /> <xsl:if test="following-sibling::record[1][@type='continuation']"> <xsl:apply-templates select=following-sibling::record[1]"/> </xsl:if> </xsl:template> However, this gives me a stack overflow error in Xalan (which I'm stuck with for now). Actually, it gives me a stack overflow in Saxon too -- I probably need to use named templates or something to get the tail recursion optimization to work. > To put it in other words, this is not a recursion that processes the > elements of a *known* list, but one that scans a list to find > a specific > element (in this case record with type="normal"). Exactly. I thought there still might be a way to implement DVC if one could make the list "known" somehow in some efficient way (keys, or some other xsl magic). > Often something like binary search can be used to speed up such linear > recursion, but I don't know if this can be used in this specific case. How would one do this (for a binary search, don't you again need a known search space?) What information do you need in order to tell me if it can be done for this case? Cheers, Raman Gupta XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] how to estimate speed of , Gupta, Raman K [CI] | Thread | [xsl] Re: Re: Re: Unbounded element, Dimitre Novatchev |
Re: [xsl] how to estimate speed of , Kevin Jones | Date | Re: [xsl] how to estimate speed of , David Tolpin |
Month |