Subject: [xsl] RE : [xsl] recursivity and param From: "Xavier Boully" <xavier.boully@xxxxxxxxxxxxxxxx> Date: Thu, 12 Aug 2004 15:42:35 +0200 |
My example was too simple to represent my need. But it doesn't matter as you gave a good answer to the general question that was the real need. You are right, going to the first child and the next sibling is the perfect way to scan the whole tree with the best control on nodes. As I briefly think of this, we get a better symmetry between the width and depth of a tree than with the common way of taking all the children. In an other context than XSLT, this method oblige to think of 2 stopping conditions, one for the depth direction and one for the width direction. I am particularly happy with this symmetry as it is easier then to separate the tree scan process from the calculation needed for a problem whatever it is. Thanks Dimitre Xavier -----Message d'origine----- De : Dimtre Novatchev [mailto:dnovatchev@xxxxxxxxx] Envoyi : jeudi 12 ao{t 2004 13:53 @ : xsl-list@xxxxxxxxxxxxxxxxxxxxx m Objet : Re: [xsl] recursivity and param As other people have pointed out, the specific problem you provide does not require recursive processing at all -- a simple XPath expression suffices. The answer to your more general question (in case I understand it correctly) is provided by the Tree Visitor pattern, which is a generic pattern of transformation by visiting every node in a sequential (document) order. This provides for the finest level of granularity possible with XSLT. An obvious shortcoming may be the very deep recursive processing, however there are proven ways to solve this problem -- e.g. the DVC (Divide and Conquer) approach. As is the case with other patterns, because of its poer and generality, it should be used only when there are no other, more direct and efficient ways to solve a given problem. For detailed code see: http://www.biglist.com/lists/x sl-list/archives/200402/msg008 66.html Cheers, Dimitre Novatchev. On Thu, 12 Aug 2004 12:32:35 +0200, Xavier Boully <xavier.boully@xxxxxxxxxxxxxxx m> wrote: > I would like to use recursivity through the source document with XSLT > 1.0 and no extension. > > As far as I understood, when I am at a node level, I have a context > that I can pass to children level using with-param. But what I would > like to obtain is to catch things from children treatment to influence > the context of the node level: when I pass context to a certain child > I would like to take in account things that happened before while > processing children I met before (in order of source document for > example). > > Reading again that question make me think that it is maybe not clear > enough. Let's try an example. > - Suppose that in source tree we have some <to-copy-element /> > elements > - Suppose that I just want my XSLTransformation to copy to the result tree > the <to-copy-element /> from the source tree. > - Suppose that I add a condition that I must not copy more than 10 > <to-copy-element />. In other words I want to copy only the first (in order > of source document) 10 <to-copy-element /> elements or all the > <to-copy-element /> elements if count(//to-copy-element)<11. > > I think (but this is maybe a wrong hypothesis) that at a given node > level, I have to pass to a child information about the number of > copies done with children processed before. > > Any ideas ? > > Xavier
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] recursivity and param, Dimtre Novatchev | Thread | RE: [xsl] recursivity and param, Joe Fawcett |
Re: [xsl] Tags to HTML page, David Carlisle | Date | RE: [xsl] Tags to HTML page, Michael Kay |
Month |