Calling a template recursively??
-
Here is an example: Call Sequence "We make a living by what we get, we make a life by what we give." --Winston Churchill
-
its giving an error The XSL processor stack has overflowed - probable cause is infinite template recursion what should be the termination condition in this?
Rocky You can't climb up a ladder with your hands in your pockets.
is the recursive call and will be called if "CallSequence" is a child of itself at any point. If you call this more than once within your xsl:for-each loop, you will run out of stack. Also, it should return once it does not find another child "CallSequence"; however, if your xsl:for-each does not account for a recursive call, it will cause an out-of stack error also. It is very hard to troubleshoot a large template with nested xsl:for-each loops. I advise you to break up your code into several templates. XSLT is functional in nature and you should keep nested levels of xsl:for-each to a minimum. "We make a living by what we get, we make a life by what we give." --Winston Churchill
-
is the recursive call and will be called if "CallSequence" is a child of itself at any point. If you call this more than once within your xsl:for-each loop, you will run out of stack. Also, it should return once it does not find another child "CallSequence"; however, if your xsl:for-each does not account for a recursive call, it will cause an out-of stack error also. It is very hard to troubleshoot a large template with nested xsl:for-each loops. I advise you to break up your code into several templates. XSLT is functional in nature and you should keep nested levels of xsl:for-each to a minimum. "We make a living by what we get, we make a life by what we give." --Winston Churchill
OK that looks helpful to me! Please tell what this statement is doing in the example code you've given, When I changed the . to CallSequence it doesnt show anything (atleast the error is gone) but when i put this as you have given it runs out of stack. right now I'm just trying to run your code in order to make an understanding of the template I wanna make at the moment. After I'm done with this I'll concentrate on embedding it in the whole this as a sepearte function like you said Rocky You can't climb up a ladder with your hands in your pockets.
-
is the recursive call and will be called if "CallSequence" is a child of itself at any point. If you call this more than once within your xsl:for-each loop, you will run out of stack. Also, it should return once it does not find another child "CallSequence"; however, if your xsl:for-each does not account for a recursive call, it will cause an out-of stack error also. It is very hard to troubleshoot a large template with nested xsl:for-each loops. I advise you to break up your code into several templates. XSLT is functional in nature and you should keep nested levels of xsl:for-each to a minimum. "We make a living by what we get, we make a life by what we give." --Winston Churchill
well now I've changed the to and its showing the output BUT... as I was thinking... the Call Node that has other CallSequence nodes is comming out at the end bcz of the stack. Actually the calling function should come at the top rather than at the bottom. Right now I'm thinking abt another way around. How abt if I use a template to display the Nodes inside a Call and if there is yet another CallSequence I call that template again (using Call-template) with the new Node Set. Rocky You can't climb up a ladder with your hands in your pockets.
-
is the recursive call and will be called if "CallSequence" is a child of itself at any point. If you call this more than once within your xsl:for-each loop, you will run out of stack. Also, it should return once it does not find another child "CallSequence"; however, if your xsl:for-each does not account for a recursive call, it will cause an out-of stack error also. It is very hard to troubleshoot a large template with nested xsl:for-each loops. I advise you to break up your code into several templates. XSLT is functional in nature and you should keep nested levels of xsl:for-each to a minimum. "We make a living by what we get, we make a life by what we give." --Winston Churchill
-
OK that looks helpful to me! Please tell what this statement is doing in the example code you've given, When I changed the . to CallSequence it doesnt show anything (atleast the error is gone) but when i put this as you have given it runs out of stack. right now I'm just trying to run your code in order to make an understanding of the template I wanna make at the moment. After I'm done with this I'll concentrate on embedding it in the whole this as a sepearte function like you said Rocky You can't climb up a ladder with your hands in your pockets.
Sorry, my mistake. The "." means current node. It should be "CallSequence".
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
Call to
Object Type
Object Name
Interface Name
Return Code
Inputs
Inputs
Output----------------- I've almost done it!! the calling doesnt go to the third level so I call it this way...
You just have to remember that xsl:call-template works with the current node and doesn't change scope like xsl:apply-templates. Also, xsl:apply-templates has a mode attribute that is used to name it like xsl:call-templates and you can pass parameters to it also.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
You just have to remember that xsl:call-template works with the current node and doesn't change scope like xsl:apply-templates. Also, xsl:apply-templates has a mode attribute that is used to name it like xsl:call-templates and you can pass parameters to it also.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
wht does it mean when we say that call-template doesnt change scope? bcz after this statement the xsl:template gets called right? so we can change the scope inside the template right?
Rocky You can't climb up a ladder with your hands in your pockets.
xsl:call-template has is own "scope" as far as variable creation. But the scope of the current node and node-list is the same as its calling parent.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
xsl:call-template has is own "scope" as far as variable creation. But the scope of the current node and node-list is the same as its calling parent.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
OK! can u tel me how can we get the parent node of the current node. I was thinking that while traversing through the $nodeset I shoujld chk for the existance of another CallSequence Node and the call the same template again recursively. Rocky You can't climb up a ladder with your hands in your pockets.
-
OK! can u tel me how can we get the parent node of the current node. I was thinking that while traversing through the $nodeset I shoujld chk for the existance of another CallSequence Node and the call the same template again recursively. Rocky You can't climb up a ladder with your hands in your pockets.
It can be "parent::node()" or "parent::*". I think you can specifically check if the parent has a specific name by using "parent::CallSequence"!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
It can be "parent::node()" or "parent::*". I think you can specifically check if the parent has a specific name by using "parent::CallSequence"!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
I was thinking abt starting a new articles on this but then I changed my mind again... I'm back to the recursive solution again bcz the previous one wasn't showing the right sequence and this recursive one gets a nodeset missed when it starts recursion. I'm giving the template I made and the XML I'm using. Here comes the Template! Recursive Solution
Call to
Object Type
Object Name
Interface Name
Return Code
Inputs
-
It can be "parent::node()" or "parent::*". I think you can specifically check if the parent has a specific name by using "parent::CallSequence"!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
I've found why this is missing the calling functions data As you can see this isthe basic model of recursion I'm using which was proposed by you previously. What happens is that that this condition in the choose-when actually doesnt consider whether there are some nodes above another CallSequence Clause. -------------- see this section of XML Unit ChemSepUO_382 ICapeUnit Calculate -------------- I've tried to change the conditions but its no help Rocky You can't climb up a ladder with your hands in your pockets.
-
It can be "parent::node()" or "parent::*". I think you can specifically check if the parent has a specific name by using "parent::CallSequence"!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
FINALLY !! I've DONE it... The EUREKA moment has come and I thought I should tell u first? Thanks a lot George... Its been a pleasure! "We make a living by what we get, we make a life by what we give." --Winston Churchill That's definately true!
Rocky You can't climb up a ladder with your hands in your pockets.
-
FINALLY !! I've DONE it... The EUREKA moment has come and I thought I should tell u first? Thanks a lot George... Its been a pleasure! "We make a living by what we get, we make a life by what we give." --Winston Churchill That's definately true!
Rocky You can't climb up a ladder with your hands in your pockets.
Congrats! :-D I bet you learned a lot about XSLT doing this exercise. Make sure you write down what you experienced for future reference.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
Congrats! :-D I bet you learned a lot about XSLT doing this exercise. Make sure you write down what you experienced for future reference.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
Congrats! :-D I bet you learned a lot about XSLT doing this exercise. Make sure you write down what you experienced for future reference.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
hi how ru doing? Can u plz tell me how i can get the distint nodes in an XML. I've searched and found these two options distinct-nodes function for-each-group function and the distinct-values function but I havent been able to use them properly. They belong to XSLT 2.0 and well seems to me like somethings missing. Either the namespace or something? how should I declare it? and I've also visited the saxon website. What exactly do i need to download from there?? I'm confused ? thanks in advance
Rocky You can't climb up a ladder with your hands in your pockets.
-
hi how ru doing? Can u plz tell me how i can get the distint nodes in an XML. I've searched and found these two options distinct-nodes function for-each-group function and the distinct-values function but I havent been able to use them properly. They belong to XSLT 2.0 and well seems to me like somethings missing. Either the namespace or something? how should I declare it? and I've also visited the saxon website. What exactly do i need to download from there?? I'm confused ? thanks in advance
Rocky You can't climb up a ladder with your hands in your pockets.
Actually, I am still studying XSLT 2.0 and haven't looked at those functions yet. If I get a chance, I'll play around with those functions a bit. Saxon-SA 8.9 is the commercial XSLT 2.0 product and Saxon-B 8.9 is the open source one. I believe both products for .NET are really written in Java underneath. Here is the linke again: http://saxon.sourceforge.net/[^].
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
Actually, I am still studying XSLT 2.0 and haven't looked at those functions yet. If I get a chance, I'll play around with those functions a bit. Saxon-SA 8.9 is the commercial XSLT 2.0 product and Saxon-B 8.9 is the open source one. I believe both products for .NET are really written in Java underneath. Here is the linke again: http://saxon.sourceforge.net/[^].
"We make a living by what we get, we make a life by what we give." --Winston Churchill