![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: xslt problem for-each loop >Thread Next - Re: xslt problem for-each loop Re: xslt problem for-each loopTo: NULL Date: 5/7/2004 11:40:00 AM I have one further question i can't seem to solve if anyone can help.
I now have the following xml input file.
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="C:\Documents and
Settings\Administrator\Desktop\Avail\unavailabilty.xsl"?>
<un>
<unavailable>
<timeline>111111111111111000000000111111111111111111111111111111111111111111
1111111111111111110101010101001010</timeline>
<date>19/01/2004</date>
<candidateid>john</candidateid>
</unavailable>
<unavailable>
<timeline>010100101010100000000000111111111111111111111111111111111111111111
1111111111111111110101010101001010</timeline>
<date>20/01/2004</date>
<candidateid>chris</candidateid>
</unavailable>
</un>
I want to be able to create a timeline for each date at the moment the xsl
is duplicating the html header table i just want <td> row when the timeline
count is greater than 1.
xsl attached it visually expains whats going wrong.
thanks.
xsl:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/un/unavailable">
<html>
<head>
<script src="file:///C|/Documents and
Settings/Administrator/Desktop/Avail/avail.js" type="text/javascript"/>
<link
href="file:///C|/Documents%20and%20Settings/Administrator/Desktop/Avail/avai
l.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- header section for week num and Timeline intervals-->
<table width="1003" border="0" cellpadding="1" cellspacing="0"
bgcolor="#0066CC">
<tr valign="top" bgcolor="#7b9ebd" class="style7">
<td width="115" height="28" align="right" valign="middle">Time Periods:</td>
<td width="108" valign="middle">
<select name="select">
<option>Hourly</option>
<option>1/2 Hourly</option>
<option>1/4 Hourly</option>
</select>
</td>
<td width="77" align="right" valign="middle">Week No:</td>
<td width="86" align="center" valign="middle">
<table width="46" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10">
<input name="textfield" type="text" class="style19" size="2" maxlength="2"/>
</td>
<td width="36">
<img
src="file:///C|/Documents%20and%20Settings/Administrator/Desktop/Avail/image
s/btn_off_cal.gif" width="36" height="19"/>
</td>
</tr>
</table>
</td>
<td width="607"> </td>
</tr>
</table>
<!-- end of section for week num and Timeline intervals-->
<!--start of timeline section-->
<table border="1" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF"
OnMousedown="mouseDown(event)" onMouseUp="lmouseup()"
onMouseMove="changeto(event)">
<tr bgcolor="#7b9ebd">
<td align="center" class="style9" id="ignore">Week Day</td>
<td align="center" class="style9">Week Date </td>
<td colspan="4" class="style7">00:00</td>
<td colspan="4" class="style7">01:00</td>
<td colspan="4" class="style7">02:00</td>
<td colspan="4" class="style7">03:00</td>
<td colspan="4" class="style7">04:00</td>
<td colspan="4" class="style7">05:00</td>
<td colspan="4" class="style7">06:00</td>
<td colspan="4" class="style7">07:00</td>
<td colspan="4" class="style7">08:00</td>
<td colspan="4" class="style7">09:00</td>
<td colspan="4" class="style7">10:00</td>
<td colspan="4" class="style7">11:00</td>
<td colspan="4" class="style7">12:00</td>
<td colspan="4" class="style7">13:00</td>
<td colspan="4" class="style7">14:00</td>
<td colspan="4" class="style7">15:00</td>
<td colspan="4" class="style7">16:00</td>
<td colspan="4" class="style7">17:00</td>
<td colspan="4" class="style7">18:00</td>
<td colspan="4" class="style7">19:00</td>
<td colspan="4" class="style7">20:00</td>
<td colspan="4" class="style7">21:00</td>
<td colspan="4" class="style7">22:00</td>
<td colspan="4" class="style7">23:00</td>
<td colspan="4" class="style7">24:00</td>
</tr>
<!--end of timeline section-->
<!-- start of day times section-->
<tr>
<td bgcolor="#7b9ebd" class="style15" id="ignore">Monday</td>
<td bgcolor="#7b9ebd" class="style15"><xsl:value-of
select="date"></xsl:value-of></td>
<xsl:apply-templates select="timeline"/>
</tr>
</table>
<!-- <td class="unnamed2"> </td>s-->
<!-- end of day times section -->
<!--Start of section for planner legend -->
<table width="800" border="1" cellpadding="1" cellspacing="0"
bordercolor="#FFFFFF">
<tr>
<td width="154" class="style9">Planner Legend: </td>
<td width="29" bordercolor="#000000" bgcolor="#0000FF" class="style18"
onMouseDown="changehighlightcolor('blue')"> </td>
<td width="216" align="center" class="style15"> Regular Unavailabilty</td>
<td width="36" bordercolor="#000000" bgcolor="#FF0000" class="style18"
onMouseDown="changehighlightcolor('red')"> </td>
<td width="190" align="center" class="style15">Requirements</td>
<td width="36" bordercolor="#000000" bgcolor="#009900" class="unnamed2"
onMouseDown="changehighlightcolor('green')"> </td>
<td width="179" align="center" class="style15">Specific Unavailability</td>
<td width="36" align="center" bordercolor="#000000" class="unnamed2"
onMouseDown="changehighlightcolor('white')"> </td>
<td width="123" align="center" class="style15">Delete Times </td>
</tr>
<tr>
<td colspan="9" class="style19">Please click a colour then drag & drop
unavailability, Right click button to edit unavailbilty description and
notes. </td>
</tr>
</table>
<!-- end of section for planner legend -->
</body>
</html>
</xsl:template>
<xsl:template name="timeline">
<xsl:param name="str"/>
<xsl:param name="pos"/>
<xsl:if test="string-length($str) >= $pos">
<xsl:if test="substring($str,$pos,1) = '1'">
<td bgcolor="#00FF00"> </td>
</xsl:if>
<xsl:if test="substring($str,$pos,1) = '0'">
<td bgcolor="#0000FF"> </td>
</xsl:if>
<!-- <td>
<xsl:value-of select="substring($str, $pos, 1)"/>
</td>
</timeline>-->
<xsl:call-template name="timeline">
<xsl:with-param name="str" select="$str"/>
<xsl:with-param name="pos" select="$pos + 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="timeline">
<xsl:call-template name="timeline">
<xsl:with-param name="str" select="text()"/>
<xsl:with-param name="pos" select="1"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
"Chris Millar" <chris.millar@e...> wrote in message
news:emgmSeBNEHA.2488@T......
> Its ok i managed to sort it, had to do a template match="/" thanks for the
> help on this Yan.
>
> "Chris Millar" <chris.millar@e...> wrote in message
> news:%23TiT%23GBNEHA.2488@T......
> > This doesn't seem to work output is as follows:
> >
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#0000FF">Â </td>
> > <td bgcolor="#0000FF">Â </td>
> > <td bgcolor="#0000FF">Â </td>
> > <td bgcolor="#0000FF">Â </td>
> > <td bgcolor="#0000FF">Â </td>
> > <td bgcolor="#0000FF">Â </td>
> > <td bgcolor="#0000FF">Â </td>
> > <td bgcolor="#0000FF">Â </td>
> > <td bgcolor="#0000FF">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> > <td bgcolor="#00FF00">Â </td>
> >
> > the <html> tags do not seem to be included.
> >
> > chris.
> >
> > "Yan Leshinsky" <yanl@o...> wrote in message
> > news:%23hcUo$8MEHA.2064@T......
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <xsl:stylesheet version="1.0"
> > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> > > <xsl:output method="html" version="1.0" encoding="UTF-8"
indent="yes"/>
> > >
> > > <xsl:template name="timeline">
> > > <xsl:param name="str"/>
> > > <xsl:param name="pos"/>
> > > <xsl:if test="string-length($str) >= $pos">
> > > <xsl:if test="substring($str,$pos,1) = '1'">
> > > <td bgcolor="#00FF00"> </td>
> > > </xsl:if>
> > > <xsl:if test="substring($str,$pos,1) = '0'">
> > > <td bgcolor="#0000FF"> </td>
> > > </xsl:if>
> > > <!-- <td>
> > > <xsl:value-of select="substring($str, $pos, 1)"/>
> > > </td>
> > > </timeline>-->
> > >
> > > <xsl:call-template name="timeline">
> > > <xsl:with-param name="str" select="$str"/>
> > > <xsl:with-param name="pos" select="$pos + 1"/>
> > > </xsl:call-template>
> > > </xsl:if>
> > > </xsl:template>
> > >
> > > <xsl:template match="timeline">
> > > <xsl:call-template name="timeline">
> > > <xsl:with-param name="str" select="text()"/>
> > > <xsl:with-param name="pos" select="1"/>
> > > </xsl:call-template>
> > > </xsl:template>
> > >
> > > <xsl:template name="header">
> > > <html>
> > > <head>
> > > <title/>
> > > </head>
> > > <body><xsl:apply-templates select="timeline"/></body>
> > > </html>
> > > </xsl:template>
> > >
> > > </xsl:stylesheet>
> > >
> > > "news.microsoft.com" <chris.millar@e...> wrote in message
> > > news:OwEdhs7MEHA.2708@T......
> > > > thank you for you help on this and it seems to work i have extended
it
> > to
> > > > make a <td bgcolor="#00FF00"></td> for 0 in timeline and <td
> > > > bgcolor="#0000FF"></td>
> > > >
> > > > i want to be able to put this inside of <html><head>body> tags to
make
> > > > correct html i can't seem to get it working with the two templates
> being
> > > > called the same name.
> > > >
> > > > xsl below:
> > > >
> > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > <xsl:stylesheet version="1.0"
> > > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> > > > <xsl:output method="html" version="1.0" encoding="UTF-8"
> indent="yes"/>
> > > > <xsl:template name="timeline">
> > > > <xsl:param name="str"/>
> > > > <xsl:param name="pos"/>
> > > > <xsl:if test="string-length($str) >= $pos">
> > > > <xsl:if test="substring($str,$pos,1) = '1'">
> > > > <td bgcolor="#00FF00"> </td>
> > > > </xsl:if>
> > > > <xsl:if test="substring($str,$pos,1) = '0'">
> > > > <td bgcolor="#0000FF"> </td>
> > > > </xsl:if>
> > > > <!-- <td>
> > > > <xsl:value-of select="substring($str, $pos, 1)"/>
> > > > </td>
> > > > </timeline>-->
> > > > <xsl:call-template name="timeline">
> > > > <xsl:with-param name="str" select="$str"/>
> > > > <xsl:with-param name="pos" select="$pos + 1"/>
> > > > </xsl:call-template>
> > > > </xsl:if>
> > > > </xsl:template>
> > > > <xsl:template match="timeline">
> > > > <xsl:call-template name="timeline">
> > > > <xsl:with-param name="str" select="text()"/>
> > > > <xsl:with-param name="pos" select="1"/>
> > > > </xsl:call-template>
> > > > </xsl:template>
> > > > <xsl:template name="header">
> > > > <html>
> > > > <head>
> > > > <title/>
> > > > </head>
> > > > <body><xsl:call-template name="timeline"></xsl:call-template></body>
> > > > </html>
> > > > </xsl:template>
> > > > </xsl:stylesheet>
> > > > "Chris Millar" <chris.millar@e...> wrote in message
> > > > news:eQUZ0r4MEHA.2628@T......
> > > >> I have the following xml file:
> > > >>
> > > >> <?xml version="1.0" encoding="UTF-8"?>
> > > >> <untable>
> > > >> <unavail>
> > > >>
> > > >
> >
>
<timeline>111111111111111111111111111111111111111111000000000000111111111111
> > > >> 11111111111111111111111111111111111111</timeline>
> > > >> <type>1</type>
> > > >> <date>22/01/2004</date>
> > > >> </unavail>
> > > >> </untable>
> > > >>
> > > >> I have an xslt were i want to create html based on the timeline
> > > > information.
> > > >>
> > > >> For each bit in the timeline element 1 or 0 I wish to create a TD
> > element
> > > > in
> > > >> a HTML table there are always 96 bits.
> > > >>
> > > >> The background color i want to set to black if the value of the
> current
> > > >> timeline bit is 1 and red if the current timeline bit is 0.
> > > >>
> > > >> The xsl is below, the problem i have is that i don't understand how
i
> > can
> > > > do
> > > >> the template match as there aren't 96 consecutive timeline elements
> to
> > do
> > > > it
> > > >> with i.e <timeline>0</timeline><timeline>0</timeline> ... to 96.
> where
> > i
> > > >> could use <xsl:for-each>
> > > >>
> > > >>
> > > >> can anyone help.
> > > >>
> > > >>
> > > >> xsl:
> > > >>
> > > >> <?xml version="1.0" encoding="UTF-8"?>
> > > >> <!DOCTYPE xsl:stylesheet [
> > > >> <!ENTITY nbsp " ">
> > > >> ]>
> > > >> <xsl:stylesheet version="1.0"
> > > >> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > > >> xmlns:fo="http://www.w3.org/1999/XSL/Format">
> > > >> <xsl:template match="/">
> > > >> <html>
> > > >> <head>
> > > >> <script src="file:///C|/Documents and
> > > >> Settings/Administrator/Desktop/Avail/avail.js"
> type="text/javascript"/>
> > > >> <link
> > > >>
> > > >
> >
>
href="file:///C|/Documents%20and%20Settings/Administrator/Desktop/Avail/avai
> > > >> l.css" rel="stylesheet" type="text/css"/>
> > > >> </head>
> > > >> <body>
> > > >> <!-- header section for week num and Timeline intervals-->
> > > >> <table width="1003" border="0" cellpadding="1" cellspacing="0"
> > > >> bgcolor="#0066CC">
> > > >> <tr valign="top" bgcolor="#7b9ebd" class="style7">
> > > >> <td width="115" height="28" align="right" valign="middle">Time
> > > > Periods:</td>
> > > >> <td width="108" valign="middle">
> > > >> <select name="select">
> > > >> <option>Hourly</option>
> > > >> <option>1/2 Hourly</option>
> > > >> <option>1/4 Hourly</option>
> > > >> </select>
> > > >> </td>
> > > >> <td width="77" align="right" valign="middle">Week No:</td>
> > > >> <td width="86" align="center" valign="middle">
> > > >> <table width="46" border="0" cellpadding="0" cellspacing="0">
> > > >> <tr>
> > > >> <td width="10">
> > > >> <input name="textfield" type="text" class="style19" size="2"
> > > > maxlength="2"/>
> > > >> </td>
> > > >> <td width="36">
> > > >> <img
> > > >>
> > > >
> >
>
src="file:///C|/Documents%20and%20Settings/Administrator/Desktop/Avail/image
> > > >> s/btn_off_cal.gif" width="36" height="19"/>
> > > >> </td>
> > > >> </tr>
> > > >> </table>
> > > >> </td>
> > > >> <td width="607"> </td>
> > > >> </tr>
> > > >> </table>
> > > >> <!-- end of section for week num and Timeline intervals-->
> > > >> <!--start of timeline section-->
> > > >> <table border="1" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF"
> > > >> OnMousedown="mouseDown(event)" onMouseUp="lmouseup()"
> > > >> onMouseMove="changeto(event)">
> > > >> <tr bgcolor="#7b9ebd">
> > > >> <td align="center" class="style9" id="ignore">Week Day</td>
> > > >> <td align="center" class="style9">Week Date </td>
> > > >> <td colspan="4" class="style7">00:00</td>
> > > >> <td colspan="4" class="style7">01:00</td>
> > > >> <td colspan="4" class="style7">02:00</td>
> > > >> <td colspan="4" class="style7">03:00</td>
> > > >> <td colspan="4" class="style7">04:00</td>
> > > >> <td colspan="4" class="style7">05:00</td>
> > > >> <td colspan="4" class="style7">06:00</td>
> > > >> <td colspan="4" class="style7">07:00</td>
> > > >> <td colspan="4" class="style7">08:00</td>
> > > >> <td colspan="4" class="style7">09:00</td>
> > > >> <td colspan="4" class="style7">10:00</td>
> > > >> <td colspan="4" class="style7">11:00</td>
> > > >> <td colspan="4" class="style7">12:00</td>
> > > >> <td colspan="4" class="style7">13:00</td>
> > > >> <td colspan="4" class="style7">14:00</td>
> > > >> <td colspan="4" class="style7">15:00</td>
> > > >> <td colspan="4" class="style7">16:00</td>
> > > >> <td colspan="4" class="style7">17:00</td>
> > > >> <td colspan="4" class="style7">18:00</td>
> > > >> <td colspan="4" class="style7">19:00</td>
> > > >> <td colspan="4" class="style7">20:00</td>
> > > >> <td colspan="4" class="style7">21:00</td>
> > > >> <td colspan="4" class="style7">22:00</td>
> > > >> <td colspan="4" class="style7">23:00</td>
> > > >> <td colspan="4" class="style7">24:00</td>
> > > >> </tr>
> > > >> </table>
> > > >> <!--end of timeline section-->
> > > >> <!-- start of day times section-->
> > > >> <xsl:variable name="testvar">96</xsl:variable>
> > > >> <table>
> > > >> <tr>
> > > >> <td bgcolor="#7b9ebd" class="style15" id="ignore">Monday</td>
> > > >> <td bgcolor="#7b9ebd" class="style15">19/01/2004 <xsl:value-of
> > > >> select="$testvar"></xsl:value-of></td>
> > > >> </tr>
> > > >> </table>
> > > >> <!-- <td class="unnamed2"> </td>-->
> > > >> <!-- end of day times section -->
> > > >> <!--Start of section for planner legend -->
> > > >> <table width="800" border="1" cellpadding="1" cellspacing="0"
> > > >> bordercolor="#FFFFFF">
> > > >> <tr>
> > > >> <td width="154" class="style9">Planner Legend: </td>
> > > >> <td width="29" bordercolor="#000000" bgcolor="#0000FF"
> class="style18"
> > > >> onMouseDown="changehighlightcolor('blue')"> </td>
> > > >> <td width="216" align="center" class="style15"> Regular
> > > >> Unavailabilty</td>
> > > >> <td width="36" bordercolor="#000000" bgcolor="#FF0000"
> class="style18"
> > > >> onMouseDown="changehighlightcolor('red')"> </td>
> > > >> <td width="190" align="center" class="style15">Requirements</td>
> > > >> <td width="36" bordercolor="#000000" bgcolor="#009900"
> class="unnamed2"
> > > >> onMouseDown="changehighlightcolor('green')"> </td>
> > > >> <td width="179" align="center" class="style15">Specific
> > > > Unavailability</td>
> > > >> <td width="36" align="center" bordercolor="#000000"
class="unnamed2"
> > > >> onMouseDown="changehighlightcolor('white')"> </td>
> > > >> <td width="123" align="center" class="style15">Delete Times </td>
> > > >> </tr>
> > > >> <tr>
> > > >> <td colspan="9" class="style19">Please click a colour then drag
&
> > > >> drop
> > > >> unavailability, Right click button to edit unavailbilty description
> and
> > > >> notes. </td>
> > > >> </tr>
> > > >> </table>
> > > >> <!-- end of section for planner legend -->
> > > >> </body>
> > > >> </html>
> > > >> </xsl:template>
> > > >> </xsl:stylesheet>
> > > >>
> > > >>
> > > >> Cheers
> > > >>
> > > >> chris.
> > > >>
> > > >>
> > > >
> > > >
> > >
> > >
> >
> >
>
>
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
