By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

Line number using XSL-T

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.