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

Re: A simple xsl:if question from a newbie

Subject: Re: A simple xsl:if question from a newbie
From: Cristobal Galiano Fernandez <c.galiano@xxxxx>
Date: Fri, 21 Jul 2000 12:29:04 +0200
xsl if row
(1) My XML
------------------------------------------------------------------------------------

<?xml version="1.0" encoding="ISO-8859-1"?>
  <page>
     <Time>19-11-2000</Time>
     <ROWSET>
        <ROW id="0">
           <Starttime>19-11-2000 15:03</Starttime>
           <Body>blablablablabla</Body>
        </ROW>
        <ROW id="1">
            <Starttime>15-11-2000 13:40</Starttime>
            <Body>some stuf</Body>
        </ROW>
        <ROW id="2">
           <Starttime>19-11-2000 10:00</Starttime>
           <Body>some more stuf</Body>
       </ROW>
     </ROWSET>
  </page>

(2) My XSL
------------------------------------------------------------------------------------

<?xml version="1.0" encoding="ISO-8859-1"?>
  <!-- 2000-07-18. Ej-047.XSL
       2000-07-19. "Joe McDonald" <joe@xxxxxxxxxxxxxxx>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

       -Uso de: xsl:variable,xsl:if,xsl:for-each,substring()

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-->

  <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="html" indent="yes"/>

     <xsl:template match="/">
        <HTML>
        <BODY>
        <xsl:variable name="Tiempo" select="page/Time" />
        <TABLE BORDER="5">
        <CAPTION><B>Rows with Time <xsl:value-of
select="$Tiempo"/></B></CAPTION>
        <TR>
            <TH>id</TH>
            <TH>Body</TH>
        </TR>
        <xsl:for-each select="page/ROWSET/ROW">
        <!-- Debug
            Starttime= <xsl:value-of select="Starttime"/>
            Tiempo= <xsl:value-of select="substring(Starttime, 1, 10)" />

            Body= <xsl:value-of select="Body"/> -->

            <xsl:if test="substring(Starttime, 1, 10) = $Tiempo">
                <TR>
                   <TD> <xsl:value-of select="@id"/></TD>
                   <TD> <xsl:value-of select="Body"/></TD>
                </TR>
            </xsl:if>
        </xsl:for-each>

        </TABLE>
        </BODY>
        </HTML>

      </xsl:template>

  </xsl:stylesheet>

(3) My HTML
------------------------------------------------------------------------------------

<HTML>
<BODY>
<TABLE BORDER="5">
<CAPTION><B>Rows with Time 19-11-2000</B></CAPTION>
<TR>
<TH>id</TH>
<TH>Body</TH>
</TR>
<TR>
<TD>0</TD>
<TD>blablablablabla</TD>
</TR>
<TR>
<TD>2</TD>
<TD>some more stuf</TD>
</TR>
</TABLE>
</BODY>
</HTML>



=?iso-8859-1?q?Nicki=20M=F8ller?= escribió:

> Hi All,
>
> A question from a XSL-newbie.
>
> I need to compare the contents of two different
> elements "Starttime" and "Time". I have tried somthing
> like this but wihtout any luck.
>
> My XML-file looks somthing like this
> (It's actually generated by the cocoon servlet)
> ----XML-----
> <page>
> <Time>
> 19-11-2000
> </Time>
>
> <ROWSET>
> <ROW id=0>
> <Starttime>
> 19-11-2000 15:03
> </Starttime>
> <Body>
> blablablablabla
> </Body>
> </ROW>
> <ROW id=1>
> <Starttime>
> 15-11-2000 13:40
> </Starttime>
> <Body>
> some stuf
> </Body>
> </ROW>
> <ROW id=2>
> <Starttime>
> 19-11-2000 10:00
> </Starttime>
> <Body>
> some more stuf
> </Body>
> </ROW>
> </ROWSET>
> </page>
> ------------
>
> Here's my XSL file
>
> ----XSL-----
> <xsl:for-each select="ROWSET/ROW">
>         <xsl:if test="substring(Starttime, 1, 10) = {Time}">
>
>         <xsl:value-of select="Body"/>
>         </xsl:if>
> </xsl:for-each>
> -----------
>
> Unfortunately the condition never returns true.
> Is there anyone who's got some suggestions as to
> why???
>
> Any help is apperciated
>
> -Nicki
>
> ______________________________________________________
> Do You Yahoo!?
> Få en gratis @yahoo.dk-adresse på http://mail.yahoo.dk
>
>  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

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.