473,505 Members | 15,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

call template with returned value

1 New Member
Hi all,
I need to convert an XML using XSLT transformation. I want to call a template (with-param) in a loop. Intially I can call it with a default value. That template returns a value which should be passed in the next iteration. How can I achieve this?

Example:
Input:
<parent>
<commonChild><value>1000</value></commonChild>
<child1><value1>100</value1></child1>
<child1><value1>50</value1></child1>
<child1><value1>75</value1></child1>
</parent>

my output should be:
<parent1>
<commonChild><value>900</value></commonChild> (initial value - child value)
<child1><value1>100</value1></child1>
<parent>
<commonChild><value>850</value></commonChild> (previous value - child value)
<child1><value1>50</value1></child1>
<parent>
<parent>
<commonChild><value>825</value></commonChild> (previous value - child value)
<child1><value1>25</value1></child1>
<parent>
</parent1>

Thanks
Uday.
Aug 1 '07 #1
1 1292
jkmyoung
2,057 Recognized Expert Top Contributor
I'm not sure what you're doing with your parent nodes, as they don't seem to be closed off.
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="commonChild">
  2.   <xsl:apply-templates select="following-sibling::child1">
  3.     <xsl:with-param name="value" select="value">
  4.   </xsl:apply-templates>
  5. </xsl:template>
  6.  
  7. <xsl:template match="child1">
  8. <xsl:param name="value" select="0"/>
  9.   <parent>
  10.     <commonChild><value><xsl:value-of select="$value - value1"/></value</commonChild>
  11.     <xsl:copy-of select="."/>
  12.   </parent>
  13.   <xsl:apply-templates select="following-sibling::child1">
  14.     <xsl:with-param name="value" select="$value - value1"/>
  15.   </xsl:apply-templates>
  16. </xsl:template>
  17.  
Aug 7 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1894
by: inquirydog | last post by:
Hello- I, the inquirydog have a question: Using the AVT mechanism (curly brackets in an attribute value) is a great way to decrease the size of your xml document and make it more readable. Can...
2
1562
by: Remi COCULA | last post by:
When using xsl:call-template it seems that we can't use a parameter as the name of the template to call. Example : <xsl:template name="cadre"> <xsl:param name="p_contenu"/> ...
1
1909
by: Julien Phalip | last post by:
Hi everyone! I am trying to do a transformation from the xml file: <foo> <attribute>a</attribute> ... </foo> The xsl file is as follows:
2
2094
by: Julien Phalip | last post by:
Hi everyone! I am doing an XSL transformation from the following XML file: <foo> <attribute>a</attribute> </foo> The xslt file is:
2
2835
by: FrankS | last post by:
Hi All, I have a problem with an call-template cmd at xslt 1.0: With: pCall = 'ExInput' ------ I try to: <xsl:call-template name="{$pCall}"> <xsl:with-param name="pVal" select="$pValue"/>...
1
1382
by: terry.jeske | last post by:
Hello, In xalan 2.41 we were able to conditionally call a template. This appears broken in 2.6. I did glance at the call-template specfications but did not see anything that would point to this...
1
1571
by: bjam | last post by:
Hi, if I want to include a set of call template methods into my xsl file can I do that? Meaning I want to have the template method below of data_output in another file that I can use in several...
4
1544
by: Keith Chadwick | last post by:
Is it possible to, for example: <xsl:variable name="thetemplate" test="props/prop/@value"/> <xsl:call-template name="$thetemplate"/> I tried {$template} as well. Comes back as invalid qname. ...
6
2511
by: ewolfman | last post by:
Hi, Is there any way in which I can monitor / hook the Registry, and upon a call to a specific key from a specific application - swap the returned value? I was thinking of using this method...
3
7324
by: andyalean1 | last post by:
Hello, I would like to know how to set a variable for use from a return this call-template,It returns a number that I need to use.How do I set a variable to this value? <xsl:call-template...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.