Subject: RE: Hexadecimal Arithmetic From: "Chris Bayes" <Chris@xxxxxxxxxxx> Date: Thu, 31 Aug 2000 18:16:26 +0100 |
Rather cute gradient.xsl------------------------------------------------------------- <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" /> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="root"> <xsl:apply-templates /> </xsl:template> <xsl:template match="parent"> <xsl:variable name="red"><xsl:value-of select="@level" /></xsl:variable> <xsl:variable name="green">255</xsl:variable> <xsl:variable name="blue">128</xsl:variable> <div> <xsl:attribute name="style"> background-color: rgb(<xsl:value-of select="position() * (255 div (count(//parent)))" />, 255, 255); </xsl:attribute> <xsl:value-of select="." /> <xsl:apply-templates select="child"> <xsl:with-param name="red"><xsl:value-of select="position() * (255 div count(//parent))" /></xsl:with-param> <xsl:with-param name="green"><xsl:value-of select="$green" /></xsl:with-param> <xsl:with-param name="blue"><xsl:value-of select="$blue" /></xsl:with-param> </xsl:apply-templates> </div> </xsl:template> <xsl:template match="child"> <xsl:param name="red" /> <xsl:param name="green" /> <xsl:param name="blue" /> <div> <xsl:attribute name="style"> background-color: rgb(<xsl:value-of select="$red" />, <xsl:value-of select="position() * (255 div count(../child))" />, <xsl:value-of select="$blue" />); </xsl:attribute> <xsl:value-of select="." /><br /> </div> </xsl:template> </xsl:stylesheet> gradient.xml------------------------------------------------------------- <?xml version="1.0"?> <root> <parent level="1"> <child>child 1</child> <child>child 2</child> <child>child 3</child> <child>child 4</child> <child>child 5</child> </parent> <parent level="2"> <child>child 1</child> <child>child 2</child> <child>child 3</child> <child>child 4</child> <child>child 5</child> </parent> <parent level="3"> <child>child 1</child> <child>child 2</child> <child>child 3</child> <child>child 4</child> <child>child 5</child> </parent> <parent level="4"> <child>child 1</child> <child>child 2</child> <child>child 3</child> <child>child 4</child> <child>child 5</child> </parent> <parent level="5"> <child>child 1</child> <child>child 2</child> <child>child 3</child> <child>child 4</child> <child>child 5</child> </parent> </root> Ciao Chris XML/XSL Portal http://www.bayes.co.uk/xml >-----Original Message----- >From: owner-xsl-list@xxxxxxxxxxxxxxxx >[mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Chris Bayes >Sent: 31 August 2000 16:39 >To: xsl-list@xxxxxxxxxxxxxxxx >Subject: RE: Hexadecimal Arithmetic > > >It is tricky in hex so why not stick to decimal. Then of the top of my head >do something like > ><xsl:template match="parent[@level = '1']"> > <div ...> > <xsl:attribute name="style"> > color: rgb(<xsl:value-of select="count() * >5" />, 255, 255); > </xsl:attribute> > <xsl:apply-templates> > <xsl:with-param name="red"><xsl:value-of >select="count() * 5" >/></xsl:with-param> > </xsl:apply-templates> > </div> ></xsl:template> ><xsl:template match="child"> > <xsl:param name="red" /> > <div...> > <xsl:attribute name="style"> > color: rgb(<xsl:value-of select="$red" />, ><xsl:value-of select="count() >* 5" />, 255); > </xsl:attribute> > > </div> ></xsl:template> > >and variations on the theme depending on what you want. > >Ciao Chris > >XML/XSL Portal >http://www.bayes.co.uk/xml > > >>-----Original Message----- >>From: owner-xsl-list@xxxxxxxxxxxxxxxx >>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Maulik Modi >>Sent: 31 August 2000 15:45 >>To: xsl-list@xxxxxxxxxxxxxxxx >>Subject: Hexadecimal Arithmetic >> >> >> >> >>Hi, >> >>I have the following snippet of my XML data: >><root> >><parent level="1"> >><child1>some text</child1> >><child2>some more text</child2> >><parent> >><parent level="2"> >><child1>text</child1> >><child2>different text</child2> >></parent> >>.... >></root> >> >>I want to present this in a table and that's done. Now I want to >>color code each >> table row depending on the value of the "level" attribute. That's >>done. Now I >>want to give each row a different gradient of the same color >>depending on the >>value of the "level". The value of the level ranges from 1-10. I >>wanted to take >>this and use >>it with hexadecimal arithmetic. Does anyone know how? >> >>I am getting greedy now, but it would be really nice if I could do this >>dynamically as I foresee that my XML data will not be static. >> >>Any help is appreciated. >> >>Maulik >> >> >> >> >> >> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Hexadecimal Arithmetic, Chris Bayes | Thread | RE: Hexadecimal Arithmetic, Chris Bayes |
Re: replace-string() convenience fu, Joe English | Date | RE: left zero pad digit string, Robert C. Lyons |
Month |