473,378 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

help counter recursive template

Hi,

I call the sequenceNameString template with:

<xsl:when test="child::*[name() = 'sequence']">
<xsl:call-template name="sequenceNameString">
<xsl:with-param name="sequenceName" select="@name"/>
<xsl:with-param name="maxCount" select="sequence/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_name0

but want:

eAgchCodes_name0
eAgchCodes_name1
eAgchCodes_name2
.......

Any ideas why?

cheers,

//Mikael

!-- Template that create "<sequencename>_name0", "<sequencename>_name1"..-->
<xsl:template name="sequenceNameString">
<xsl:param name="sequenceName"/>
<xsl:param name="maxCount"/>
<xsl:param name="value"/>
<xsl:param name="arrayMax" select="$maxCount - 1"/>
<xsl:if test="$value &lt; $arrayMax">
<xsl:value-of
select="concat(concat($sequenceName,'_name'),$valu e)"/>
<xsl:call-template name="sequenceNameString">
<xsl:with-param name="value" select="$value + 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
Feb 9 '06 #1
2 1217
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:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

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

<xsl:template name="sequenceNameString">
<xsl:param name="sequenceName"/>
<xsl:param name="maxCount"/>
<xsl:param name="value"/>
<!-- You used xsl:param for arrayMax; should have been variable. -->
<xsl:variable name="arrayMax" select="$maxCount - 1"/>
<xsl:if test="$value &lt; $arrayMax">
<xsl:value-of
select="concat(concat($sequenceName,'_name'),$valu e)"/>
<xsl:call-template name="sequenceNameString">
<!-- The real bug was that you forgot to pass both
sequenceName and maxCount. -->
<xsl:with-param name="sequenceName" select="$sequenceName"/>
<xsl:with-param name="value" select="$value + 1"/>
<xsl:with-param name="maxCount" select="$maxCount"/>
</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
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 :...
1
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...
1
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...
3
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
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...
10
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...
11
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,...
4
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 { /* ... */ };
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.