473,670 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help counter recursive template

Hi,

I call the sequenceNameStr ing template with:

<xsl:when test="child::*[name() = 'sequence']">
<xsl:call-template name="sequenceN ameString">
<xsl:with-param name="sequenceN ame" select="@name"/>
<xsl:with-param name="maxCount" select="sequenc e/maxLength"/>
<xsl:with-param name="value" select="0"/>
</xsl:call-template></xsl:when>

I can check that the parameter values are sent to the template.
However the incrementation of value does not happen.

I get the following only once( example):

eAgchCodes_name 0

but want:

eAgchCodes_name 0
eAgchCodes_name 1
eAgchCodes_name 2
.......

Any ideas why?

cheers,

//Mikael

!-- Template that create "<sequencename> _name0", "<sequencename> _name1"..-->
<xsl:template name="sequenceN ameString">
<xsl:param name="sequenceN ame"/>
<xsl:param name="maxCount"/>
<xsl:param name="value"/>
<xsl:param name="arrayMax" select="$maxCou nt - 1"/>
<xsl:if test="$value &lt; $arrayMax">
<xsl:value-of
select="concat( concat($sequenc eName,'_name'), $value)"/>
<xsl:call-template name="sequenceN ameString">
<xsl:with-param name="value" select="$value + 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
Feb 9 '06 #1
2 1229
Haven't examined it in detail, but I note one glitch: You aren't passing
maxCount down through the recursive call.
Feb 10 '06 #2
Yep, that was it. (You're also not outputting line breaks between the
generated names, but I'll leave that as an exercise for the student.)

<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<xsl:call-template name="sequenceN ameString">
<xsl:with-param name="sequenceN ame" select="'SN'"/>
<xsl:with-param name="maxCount" select="4"/>
<xsl:with-param name="value" select="0"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="sequenceN ameString">
<xsl:param name="sequenceN ame"/>
<xsl:param name="maxCount"/>
<xsl:param name="value"/>
<!-- You used xsl:param for arrayMax; should have been variable. -->
<xsl:variable name="arrayMax" select="$maxCou nt - 1"/>
<xsl:if test="$value &lt; $arrayMax">
<xsl:value-of
select="concat( concat($sequenc eName,'_name'), $value)"/>
<xsl:call-template name="sequenceN ameString">
<!-- The real bug was that you forgot to pass both
sequenceName and maxCount. -->
<xsl:with-param name="sequenceN ame" select="$sequen ceName"/>
<xsl:with-param name="value" select="$value + 1"/>
<xsl:with-param name="maxCount" select="$maxCou nt"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

</xsl:stylesheet>
Feb 11 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
1633
by: chahnaz.ourzikene | last post by:
Hi all, This is the first i post in this newsgroup, i hope my english is not too bad... Let's get straight to the point ! I have a little probleme using threads in my little training example : I wish to create two threads in my application, one thread (the subject) will increment a variable, and another thread (the controller) will print a message saying "i am waiting..." or someting like that, until the counter of the first thread...
1
2383
by: Jon Slaughter | last post by:
I've managed to put together a template class that basicaly creates a recursive tree that lets you easily specify the "base" class of that tree and and ending notes and lets you stop the recursive process if you want. The problem now is to make a Type list so I can specify more than one node at a time to "attach" a class to. I think I will be able to handle this but I want to run the code by you guys to see there are any major design...
1
1361
by: Paul Guz | last post by:
I've discovered a quirk of .Net System.Xml.Xsl.XSLTransfrom that doesn't seem to exist in the MSXML2 transformation. When calling a recursive template for the first time, don't pass a parameter value using a variable with the same name as the parameter. This seems to cause the original value to remain constant in all recursive calls, even if you modify that value inside the template. To demonstrate: <xsl:template match="/">...
3
2478
by: IR | last post by:
Hi, I've been trying to do the following (which doesn't compile) : template<class T, class F = Example<T struct Example { F foo(); };
3
1268
by: satan | last post by:
I'm having problem to test a recursive version of a binary search algorithm. These are my codes: public class OrderedArrayList extends ArrayListClass { //default constructor public OrderedArrayList() { super(); }
10
2555
by: AsheeG87 | last post by:
Hello Everyone! I have a linked list and am trying to include a recursive search. However, I am having trouble understanding how I would go about that. I don't quite understand a recursive search....would any of you be so kind to explain it to me...maybe include some examples. I would GREATLY appreciate it!!!
11
2843
by: lenygold via DBMonster.com | last post by:
I am tryieng to convert our time consuming recursive queries too very efficient queries based on nested set model. The only problem is to convert an adjacency list model into a nested set model, with push down stack algorithm to DB2 query. The client does not want to use Stored Procedure. Please any Recurcive or CWE ideas. Thank's in advance. -- Tree holds the adjacency model
4
5430
by: andreyvul | last post by:
I have a template function like this: std::vector<std::pair<Square<T>, Triangle<T * recarrow(T a, T b, int n) { /* ... */ } template <class T> struct Square { /* ... */ };
0
8469
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8903
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7419
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5684
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4391
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2800
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 we have to send another system
2
1794
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.