473,395 Members | 1,941 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,395 software developers and data experts.

Line number using XSL-T

Hi

I have XML, it looks like this:

<root>
<shelf1>
<book>
<title>some title 1</title>
<author>some author 1</author>
</book>
<book>
<title>some title 2</title>
<author>some author 2</author>
</book>
<book>
<title>some title 3</title>
<author>some author 3</author>
</book>
<book>
<title>some title 4</title>
<author>some author 4</author>
</book>
</shelf1>
<shelf2>
<movie>
<title>some movie title 1</title>
<book_title>some title 1</book_title>
</movie>
<movie>
<title>some movie title 2</title>
<book_title>some title 4</book_title>
</movie>
</shelf2>
</root>

What I would like to do is to show all books and movies in one table. I
can do it. Problem is I don't know how to add a line number to ever row
in table.

My table looks like this.

Ln
1 some title 1 some author 1
1 some movie title 1
1 some title 2 some author 2
1 some title 3 some author 3
1 some title 4 some author 4
1 some movie title 2

And i would like it to look like this:
Ln
1 some title 1 some author 1
2 some movie title 1
3 some title 2 some author 2
4 some title 3 some author 3
5 some title 4 some author 4
6 some movie title 2

I know I can't use xsl:variables. Also position() isn't the best choice
(I think). How can I achieve what I want to achieve?

best regards
Mateusz [PEYN] Adamus
http://adamus.home.pl
Mar 20 '06 #1
2 1199
Frankly, the easiest solution is to generate the data file, then run it
through a simple text-processing stage that adds the line numbers.

If you can't do it that way for some reason, try leveraging list
position somehow rather than creating your own counter. I've got a
thought that might work, but (a) I'd want to try it before posting it
and (b) it's somewhat ugly...

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 21 '06 #2
in message <dv**********@nemesis.news.tpi.pl>, Mateusz [PEYN] Adamus
('p************@tlen.pl') wrote:
And i would like it to look like this:
Ln
1 some title 1 some author 1
2 some movie title 1
3 some title 2 some author 2
4 some title 3 some author 3
5 some title 4 some author 4
6 some movie title 2

I know I can't use xsl:variables. Also position() isn't the best choice
(I think). How can I achieve what I want to achieve?


Use position().

If there's some reason why you think you should not use position(), what
is it?

--
si***@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/
;; Sending your money to someone just because they've erected
;; a barrier of obscurity and secrets around the tools you
;; need to use your data does not help the economy or spur
;; innovation. - Waffle Iron Slashdot, June 16th, 2002

Mar 22 '06 #3

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

Similar topics

1
by: Michel | last post by:
Hi all, This is my first post, so I am very new at this. I am trying to use page-number-citation twice in my code, but the second time it just shows '0'. The output is in pdf format and I am...
2
by: Richard Haber | last post by:
I am using format-number(-1234.56,'#,##0.00;(#,##0.00)') in a stylesheet that works in every xsl processor (including MSXML2) except for the one in ..NET 1.1. I am expecting to see (1,234.56) as...
3
by: b0yce | last post by:
Hi Group, I think I have found a problem with the <xsl:element> when being transformed by the .NET xmlTransform class. When using XmlSpy for development and debugging, the <xsl:number>...
14
by: ajfish | last post by:
Hi, I am trying to allocate a unique ID to every instance of tag 'foo' in a large XML document. currently I'm doing this: <xsl:variable name="UniqueId"> <xsl:number count="foo" level="any"/>...
12
by: ajfish | last post by:
Hi, I am trying to allocate a unique ID to every instance of tag 'foo' in a large XML document. currently I'm doing this: <xsl:variable name="UniqueId"> <xsl:number count="foo" level="any"/>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...

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.