473,320 Members | 2,029 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,320 software developers and data experts.

xsl:how to traverse through a loop and increment the counter each time for all rows

I tried the below:-
Expand|Select|Wrap|Line Numbers
  1. <xsl:variable name="rowcount" select="count(../DBE:Object[@Class='A']/DBE:Attribute[@name='B']/DBE:Table/DBE:TableRow)"/> 
No. of Rows: - <xsl:value-of select="$rowcount"/>

Now i used -->
Expand|Select|Wrap|Line Numbers
  1. <xsl:for-each select="../DBE:Object[@Class='A']/DBE:Attribute[@name='B']/DBE:Table/DBE:TableRow[position() &lt; $rowcount">
  2. display some attributes
  3. </xsl:for-each>
How the counter or position will get incremented and i can display all the rows correctly?
Oct 7 '09 #1
6 4599
Dormilich
8,658 Expert Mod 8TB
@prao2005
I didn’t understand, can you elaborate that?
Oct 7 '09 #2
@Dormilich
--> [My answer]
I want to display all the rows of a table till the end of table is encountered.

So, in a way need to traverse through the loop and display first row and then automatically position() or counter should be incremented and then display the second row in the second line and so on....

Suppose no. of rows in a table = 10
Header --> A B C
row1 --> 10 abc 20
row2 --> 20 def 10
....
....
row10 --> 30 xyz 40

Please let me know how to achieve the above output?
Oct 7 '09 #3
Dormilich
8,658 Expert Mod 8TB
something like
Expand|Select|Wrap|Line Numbers
  1. <xsl:for-each select="…/DBE:TableRow">
  2. // cell 1
  3. <xsl:text>row</xsl:text>
  4. <xsl:value-of select="position()"/>
  5. // other cells
  6. </xsl:for-each>
Oct 7 '09 #4
@Dormilich
-->
I tried the below
Expand|Select|Wrap|Line Numbers
  1. <xsl:for-each select="../DBE:Object[@Class='A']/DBE:Attribute[@name='B']/DBE:Table/DBE:TableRow">
  2. <xsl:value-of select="DBE:Attribute[@name='B']/DBE:Table/DBE:TableRow[position()]/DBE:TableData[1]"/>
  3. </xsl:for-each>
Now i do not getting any values displayed....
Oct 7 '09 #5
Dormilich
8,658 Expert Mod 8TB
@prao2005
of course. I doubt that DBE:Attribute is a child of DBE:TableRow.
Oct 7 '09 #6
@Dormilich

Yes, you are right. The first and the third columns are children of DBE:TableRow while the second column is DBE:Attribute. (in below table)

Header --> A B C
row1 --> 10 abc 20
row2 --> 20 def 10


So, is there any way that i initialize n=1 then traverse a loop until the total count of rows in the table and display the values -->
Oct 7 '09 #7

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

Similar topics

9
by: Collin VanDyck | last post by:
I have a basic understanding of this, so forgive me if I am overly simplistic in my explanation of my problem.. I am trying to get a Java/Xalan transform to pass through a numeric character...
1
by: nobody | last post by:
hi there! given <!ELEMENT a (#PCDATA | x)*> <!ELEMENT x (#PCDATA)> how can I find out if x is "embedded" at the beginning <a><x>xxx</x>aaa</a> or at the end <a>aaa<x>xxx</x></a> or in the...
1
by: ouioui | last post by:
Hi, I need to use the xsl sum function like that : <xsl:value-of select="sum(CompteRendu/Compte/@number)" /> My xml source contains number with comma like that : <Compte number=447,68" ...
3
by: Andy Fish | last post by:
Hi, I'm trying to use <xsl:number> to generate a sequence number of all nodes that match a particular pattern, e.g: <xsl:template match="foo"> <xsl:copy> <xsl:attribute name="id"><xsl:number...
2
by: Tjerk Wolterink | last post by:
Don't thinkt it is possible, but maybe someone knows how to do this. I have an xml file like this: --- <?xml version="1.0" encoding="ISO-8859-1"?> <xc:xcontent...
2
by: MC | last post by:
HI to all, First excuse me but i'm xsl beginner. I'm using XSL to transform an xml file into another. I'm using a Java program for the transformation (TraX API). I would like to recover in...
6
by: pavel.repkin | last post by:
Hey! How would you do the following task? Let you have an XML tree on input. Suppose, there is a special kind of node you want to remove. Let it have "bad" name. Each "bad" node has a parent...
3
by: maxin | last post by:
I have a xml file: <E1MBXYI SEGMENT="1"> ... <CHARG>1000024187</CHARG> ... </E1MBXYI> <E1MBXYI SEGMENT="1"> ... <CHARG>1000024187</CHARG>
2
by: prao2005 | last post by:
My XML Code <DBE:Attribute name="Test1" type="Table"> <DBE:Table> <DBE:TableHeader> <DBE:TableColumn>t1</DBE:TableColumn> ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.