[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: alternate backgrounds problem...

Subject: Re: alternate backgrounds problem...
From: "james walker" <jameswalkerandy@xxxxxxxxxxx>
Date: Wed, 23 Jun 2004 09:46:26 +0100
messenger background
Thanks,
Just out of interest is there any where on the web i could look up maths functions like mod for xslt statements...?
cheers
james



From: Josh Canfield <joshcanfield@xxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  alternate backgrounds problem...
Date: Tue, 22 Jun 2004 10:21:29 -0700

You can use position() and mod on a per portlet basis because you are
calling apply-templates with a union of all the section and link
nodes.

If you named your styles using the convention back-white-0 and back-white-1

<xsl:template match="link">
<xsl:variable name="colour" select="../@colour"/>
<xsl:variable name="desclength" select="string-length(../description)"/>
<div class="back-{$colour}-{position() mod 2}">
LINK CONTENT
</div>
</xsl:template>


Josh

On Tue, 22 Jun 2004 13:41:49 +0100, james walker
<jameswalkerandy@xxxxxxxxxxx> wrote:
>
> i am creating portlets for a webpage, each portlet has any number of
> "section" divs and "link" divs in any order. I am trying to create alternate
> background colours on these divs by using the xsl. For example, for a white
> portlet, i would want:
>
> link div - no background (white)
> section div - grey background
> section div - no background
> link div - grey background
> etc.......
>
> I think i may have to do something with parameter passing but not sure how
> to tackle it. I thought about maybe counting the number of divs in each
> portlet and then saying for every even numbered div have no background and
> every odd numbered div have a coloured background. However, i dont think you
> can figure out which divs would be odd and which would be even? My xml and
> xsl is below:
>
> I have an xml file like this:
>
> <page>
> <portlet colour="white">
> <link>
> <name></name>
> </link>
> <link>
> <name></name>
> </link>
> <section>
> <name></name>
> </section>
> .......any number of mixed sections and links
> </portlets>
> <portlet colour="blue">
> <link>
> <name></name>
> </link>
> <link>
> <name></name>
> </link>
> <section>
> <name></name>
> </section>
> .......any number of mixed sections and links
> </portlets>
> </page>
>
> part of my xsl file looks a bit like this:
> <xsl:template match="portlet">
> <xsl:variable name="colour" select="@colour" />
> <div class="portlet-content" id="ne-portlet-content">
> <!-- place description in portlet -->
> <xsl:if test="string-length(description) != 0">
> <div class="back-none">
> <p><xsl:apply-templates select="description" /></p>
> </div>
> </xsl:if>
> <!-- place links/sections in portlet -->
> <xsl:apply-templates select="link | section"/> <!-- linkc |
> section-->
> </div>
> </xsl:template>
>
> <xsl:template match="link">
> <xsl:variable name="colour" select="../@colour"/>
> <xsl:variable name="desclength"
> select="string-length(../description)"/>
> <div class="back-{$colour}">
> LINK CONTENT
> </div>
> </xsl:template>
>
> <xsl:template match="section">
> <xsl:variable name="colour" select="../@colour"/>
> <xsl:variable name="desclength"
> select="string-length(../description)"/>
> <div class="back-{$colour}">
> SECTION CONTENT
> </div>
> </xsl:template>
>
> _________________________________________________________________
> It's fast, it's easy and it's free. Get MSN Messenger today!
> http://www.msn.co.uk/messenger
>
> --+------------------------------------------------------------------
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
> --+--
>
>


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
--+--


_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.