[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Accessing multiple values of an attribute
> > I have xml similar to the following > > > <Table stripes="blue red green purple"> Your first job is to tokenize this. Some processors (and EXSLT) have an xx:tokenize() extension function that makes this easy; the only other way is to use a recursive template (which isn't very difficult). Let?s say you end up with a variable $colours containing a node-set in which there are four elements whose string values are blue, red, etc, > <Boxgrp> > <Boxbod> > <Boxrow> > <Content> First Row</Content> > </Boxrow> > <Boxrow> > <Content> Second Row</Content> > </Boxrow> ...snip... > > > The number of values existing in the stripes attribute is > variable (not always 4), and the rows in the table can also > be of different numbers (i.e. I could get one with 20 rows) > Using xsl, I must access the values of the 'stripes' > attribute and colour the rows of the box.....i.e. in the > above case, the box has 6 rows and 4 different colours so I > want my rows to be coloured in the following way: > Row 1: blue > Row 2: red > Row 3: green > Row 4: purple > Row 5: blue > Row 6: red etc > " green > " purple > This is now easy: <xsl:template match="Boxrow"> <p style="color: {$colours[position() mod count($colours) + 1]}"> <xsl:value-of select="Content"/> </p> </xsl:template> Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > Question: > First of all, how do I access the different values of the > stripes attribute (is there an easy way that I have > overlooked?)? I need to know > (a) how many of them there are (for my mod function) > (b) what values they have. > > I was trying string-before and string-after but that could > get messy if I got alot of different colours. > > Thanks & Regards > > Karen > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|