473,734 Members | 2,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

18 New Member
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="$rowcou nt"/>

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 4609
Dormilich
8,658 Recognized Expert Moderator Expert
@prao2005
I didn’t understand, can you elaborate that?
Oct 7 '09 #2
prao2005
18 New Member
@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 Recognized Expert Moderator Expert
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
prao2005
18 New Member
@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 Recognized Expert Moderator Expert
@prao2005
of course. I doubt that DBE:Attribute is a child of DBE:TableRow.
Oct 7 '09 #6
prao2005
18 New Member
@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
8579
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 reference (i.e.  ) and it seems to be converting the character to its UNICODE representation. Take this source XML document: <?xml version="1.0" encoding="UTF-8"?>
1
2612
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 middle
1
3873
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" /> <Compte number="11904,66" />
3
3159
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 level="any"/></xsl:attribute> </xsl:copy> </xsl:template>
2
1956
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 xmlns:xc="http://www.wolterinkwebdesign.com/xml/xcontent" xmlns="http://www.w3.org/1999/xhtml" module="agenda"> <xc:subset offset="0" max="10" count="3"/> <xc:agendapunt> <xc:id>1</xc:id>
2
2087
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 the xsl stylesheet the value of a variable defined in my Java program. Is it possible ?
6
18978
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 node, obviously. In case there are no children left in the parent after removal of all the "bad" nodes, the parent must also be removed. And this rule is applied to all the ancetors of the "bad" node
3
2054
by: maxin | last post by:
I have a xml file: <E1MBXYI SEGMENT="1"> ... <CHARG>1000024187</CHARG> ... </E1MBXYI> <E1MBXYI SEGMENT="1"> ... <CHARG>1000024187</CHARG>
2
2969
by: prao2005 | last post by:
My XML Code <DBE:Attribute name="Test1" type="Table"> <DBE:Table> <DBE:TableHeader> <DBE:TableColumn>t1</DBE:TableColumn> <DBE:TableColumn>t2</DBE:TableColumn> <DBE:TableColumn>t3</DBE:TableColumn> <DBE:TableColumn>t4</DBE:TableColumn>
0
8948
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
8780
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
9456
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
9315
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9246
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9186
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
6035
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();...
1
3264
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
3
2182
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.