Calling a template recursively??
-
Hello everyone, well I want to make this one as simple as I can. I have an XML inwhich you can get nodes in this type of format .... Now what I'm trying to do is to traverse it recursively using just a single template to tranverse both the /LOG/CallSequence/Call and any CallSequence/Call Elements that occur inside it. So can anyone plz give me an idea of how to do this. I have made a template that traverses the outer part but i dont know how to reach the inside CallSequence/Call part???!!! Thanks in advance! Rocky You can't climb up a ladder with your hands in your pockets.
-
Hello everyone, well I want to make this one as simple as I can. I have an XML inwhich you can get nodes in this type of format .... Now what I'm trying to do is to traverse it recursively using just a single template to tranverse both the /LOG/CallSequence/Call and any CallSequence/Call Elements that occur inside it. So can anyone plz give me an idea of how to do this. I have made a template that traverses the outer part but i dont know how to reach the inside CallSequence/Call part???!!! Thanks in advance! Rocky You can't climb up a ladder with your hands in your pockets.
Here is an example: Call Sequence "We make a living by what we get, we make a life by what we give." --Winston Churchill
-
Here is an example: Call Sequence "We make a living by what we get, we make a life by what we give." --Winston Churchill
That looks preetu helpful but the problem is that the xsl I'm working on is very large and accessing the CallSequence/Call is used at two places. So I wanted to use the same template for both. that is for outer as well the inner occurence. The XML can contain any number of call sequences within a call as u know a method can call another method and that can call yet another one so what i'm trying to do is to develop a template which i can call by passing it the set of nodes. Then it should display it. by the way if we use xsl:template match="CallSequence"... is it able to get all the CallSequence nodes as we traverse down the tree??
Rocky You can't climb up a ladder with your hands in your pockets.
-
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.