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

Re: xsl:variable with hex color values

Subject: Re: xsl:variable with hex color values
From: Rolando Isidoro <rli@xxxxxxxxxx>
Date: Sun, 22 May 2005 16:59:50 +0100
hex color test
Michael Kay wrote:

Another solution to add to the list you've been given: In XSLT 2.0 you can
do

<td bgcolor="{if (position() mod 2) then 'black' else 'white'}">
 ...
</td>

If you want to be terse and don't mind being obscure, you can write things
in XSLT 1.0 like

<td bgcolor="#{substring('FFFFFF000000', (position() mod 2 * 6) + 1, 6)}">
 ...
</td>

Michael Kay


I've tried the solution you've mentioned and got "Error loading stylesheet: Parsing an XPath expression failed".
Here's the XML and XSL documents I've used:


<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="teste.xsl"?>

<tests>
   <test>
       1
   </test>
   <test>
       2
   </test>
   <test>
       3
   </test>
   <test>
       4
   </test>
</tests>


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2004/07/xpath-functions" xmlns:xdt="http://www.w3.org/2004/07/xpath-datatypes">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<head/>


           <body>
               <table>

<xsl:for-each select="//test">
<tr>
<td bgcolor="{if (position() mod 2) then 'black' else 'white'}">
<xsl:value-of select="."/>
<br/>
</td>
</tr>


</xsl:for-each>

</table>

           </body>
       </html>

   </xsl:template>
</xsl:stylesheet>

Is something wrong with this example? How can I solve the problem?

Thank you for your assistance, regards, Rolando

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.