Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 9th, 2008, 09:21 AM
Authorized User
 
Join Date: Jul 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to set the backgound-color dynamically

Here m having a xml as:
<NewDataSet>
  <Detail>
    <idShiftNo>68</idShiftNo>
    <idEmployee>221263</idEmployee>
    <NameEmployee>Biswal, Sabine</NameEmployee>
    <Date>2007-01-05T00:00:00+05:30</Date>
    <Department>1</Department>
    <ShiftName>N2</ShiftName>
    <ShiftStart>2007-01-05T21:15:00+05:30</ShiftStart>
    <ShiftEnd>2007-01-05T22:00:00+05:30</ShiftEnd>
    <idTaskNo>323</idTaskNo>
    <strNameJob>BO</strNameJob>
    <idTaskNo1>323</idTaskNo1>
    <TaskStart>2007-01-05T21:15:00+05:30</TaskStart>
    <TaskEnd>2007-01-05T21:55:00+05:30</TaskEnd>
    <TaskName>OS217</TaskName>
    <intSchriftFarbe>0</intSchriftFarbe>
    <intHintergrundFarbe>12632256</intHintergrundFarbe>
  </Detail>


Then m using xslt so if used it as:
 <xsl:variable name ="taskname1" select ="intHintergrundFarbe"></xsl:variable>

<table>
                      <tr>
                        <td width="{$timestartshow}" id="name">
                          <div style="width:0;background-color:white; solid #000;">

                          </div>
                        </td>
                        <td>
                          <div style="width:{$timeendshow}; background-color:{$taskname1}; solid #000;">

                            <xsl:value-of select ="$taskname"/>

                          </div>
                        </td>

                      </tr>
                    </table>
it can't show the background color. so please help me in this case as in xslt how the div background-color changes dynamically
Please help me:(

 
Old July 9th, 2008, 09:47 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

According to your sample data intHintergrundFarbe is equal to 12632256. This is not a valid HTML colour.

/- Sam Judson : Wrox Technical Editor -/
 
Old July 9th, 2008, 09:49 AM
Authorized User
 
Join Date: Jul 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

so how should i convert it in Html format???


 
Old July 9th, 2008, 10:18 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I don't know - its not in any valid colour format that I've ever come across.

/- Sam Judson : Wrox Technical Editor -/
 
Old July 10th, 2008, 01:47 AM
Authorized User
 
Join Date: Jul 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

sir, as m searching on this, i come to know that this color code belongs to the access front-end color scheme, so now will u please help me to convert it into html color dynamically.
Thanx for ur reply :)


 
Old July 10th, 2008, 03:16 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Ah, Microsoft Access - wonderful.

Well if your number is C then in terms of RGB colours it is C = R + G * 256 + B * 256 * 256
If you work this backwards using something like below you can get to R, G and B again:

    B = Int(C / 256 / 256)
    G = Int((C - B * 256 * 256) / 256)
    R = Int(C - B * 256 * 256 - G * 256)

However then you have a number between 0 and 255 - which you then have to convert into hex to supply as a HTML colour.

I hope that helps. From there I think you'll have to do the rest yourself as I don't have any more time.

/- Sam Judson : Wrox Technical Editor -/
 
Old July 10th, 2008, 03:41 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your HintergrundFarbe 12632256 translates to hexadecimal as C0C0C0, which looks like a plausible RGB colour code, so I suspect you just want to do a decimal-to-hex translation. You can do that either by calling an extension function, or by writing it yourself as a recursive function (or template, if you're in XSLT 1.0). Or in fact as it's always six hex digits you could just compute each digit separately: the hex value of the 4th hex digit for example is

substring("0123456789ABCDEF", 1 + (($in div 256) mod 16), 1)

Michael Kay
http://www.saxonica.com/

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 10th, 2008, 07:17 AM
Authorized User
 
Join Date: Jul 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx for all of u as now m atleast got an idea as how to convert it.
Thanx a lot!!! :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
change the color of selected text dynamically NEO1976 Flash (all versions) 1 December 18th, 2007 11:11 AM
how we can set background color in xslt abhi.prince4u XSLT 2 July 4th, 2007 02:22 AM
Set Background color using RGb value sudarshan73 Reporting Services 1 January 11th, 2007 03:35 PM
CSS Backgound / Color warnings socoolbrewster CSS Cascading Style Sheets 3 January 4th, 2007 08:15 AM
set text color larry Javascript How-To 9 July 8th, 2004 01:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.