At 2003-05-27 14:32 +0200, Andreas Byström wrote:
I'm about to make web page that should have a table of names in it. I would
like to have different background color on each other ro in the table,
example:
black
white
black
white...
I have trouble getting this to work with the XSL. This is an example on the
xml I have to work with
<pack>
<service>
<name>name1</name>
</service>
<service>
<name>name2</name>
</service>
</pack>
<pack>
<service>
<name>name3</name>
</service>
<service>
<name>name4</name>
</service>
</pack>
I want to list all services names. I managed to solve it when I only had one
<pack> tag, but now I can have several pack-tags. Does someone know how to
get a nice table from this data?
At the point where you are at the parent element of <pack> the pseudo-code
would be the following:
For each in "pack/service": #this XPath addr selects all service
grandchildren
<tr>
when position() mod 2 = 0
Add black background attribute
otherwise
Add white background attribute
Add content of <tr> element
</tr>
Note that in the above all service grandchildren are treated as a single
set, so the pack boundaries do not interfere with the positioning of the
members of the set relative to each other.
Also ensure that you add any attributes to a result element *before* you
add any content to the row.
I hope this helps.
....................... Ken
--
Upcoming hands-on courses: (registration still open!)
- (XSLT/XPath and/or XSL-FO) North America: June 16-20, 2003
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6 Definitive XSLT and XPath
ISBN 0-13-140374-5 Definitive XSL-FO
ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners: http://XMLGuild.info
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list