You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Steve Belt <sb...@velos.com> on 2000/02/29 18:28:31 UTC

Best approach to display calendar

Hello:

First, I'd like to say how much I am impressed with Cocoon. I really wowed
some people in my company when I showed them how Cocoon could feed the same
XML to both a web browser and a WAP device (Nokia Emulator), reformatted for
each.

I am trying to use Cocoon to display a calendar using an XML provided by my
database. I would like to display the events, in HTML, formatted as you see
in most scheduling applications (Table listing all hours of the day, then
showing events, if any, in the adjoining cell). I can create an XSL which
will create a table row for each event, however, I do not know how I can
display hours and cells which have no events to them. The XSL examples I can
find, in a manner of speaking, are "triggered" by elements in the XML; I, on
the other hand, need to display tags

As I read through the documentation on Cocoon, I see several possible
choices:

 I could manipulate my XML to match my calendar - ie, include nodes for
hours that do not have events. However, this makes my XML less generic.

I could use XSP to manipulate the original XML to insert the empty nodes,
but I am not fluent in XSP, and am having trouble seeing how to do this.

Finally, perhaps this can all be handled by the XSL. However, as you can no
doubt tell, I still have much to learn, and I cannot find any examples which
show me how to accomplish this. Also, I want to be able to change my time
intervals - ie 1-cell/hour, or 1-cell/half-hour, etc

So, as I started out saying, I want to use Cocoon to provide this page.
Anybody have any suggestions on how I should proceed? Which of Cocoon's
technologies should I be concentrating on? Any example source code (I saw
Jetspeed, but They are using Turbine)?

Thanks in Advance,

Steve


Re: Best approach to display calendar

Posted by Phil Lanch <ph...@aldigital.co.uk>.
Steve Belt wrote:
> 
> I am trying to use Cocoon to display a calendar using an XML provided by my
> database. I would like to display the events, in HTML, formatted as you see
> in most scheduling applications (Table listing all hours of the day, then
> showing events, if any, in the adjoining cell). I can create an XSL which
> will create a table row for each event, however, I do not know how I can
> display hours and cells which have no events to them. The XSL examples I can
> find, in a manner of speaking, are "triggered" by elements in the XML; I, on
> the other hand, need to display tags
> 
> As I read through the documentation on Cocoon, I see several possible
> choices:
> 
>  I could manipulate my XML to match my calendar - ie, include nodes for
> hours that do not have events. However, this makes my XML less generic.

just so.

> I could use XSP to manipulate the original XML to insert the empty nodes,
> but I am not fluent in XSP, and am having trouble seeing how to do this.

me too - but i don't know much about XSP.

> Finally, perhaps this can all be handled by the XSL. However, as you can no
> doubt tell, I still have much to learn, and I cannot find any examples which
> show me how to accomplish this. Also, I want to be able to change my time
> intervals - ie 1-cell/hour, or 1-cell/half-hour, etc

i'd do it this way.

to "iterate" over 0 to 23 hrs (or 9 to 17 ...) when not all those
numbers are in the source doc, XSL has to use a tail-recursive named
template.  when the <event>s are children of the current node, you can
say-

<xsl:call-template name="calendar"/>

-to call something like this template-

<xsl:template name="calendar">
  <!-- declare "iterator": -->
  <xsl:param name="hour" select="0"/>
  <!-- do this row: -->
  <tr>
    <td><xsl:value-of select="$hour"/> hrs</td>
    <td><xsl:apply-templates select="event[time/hour = $hour]"/></td>
  </tr>
  <!-- if not finished, recurse: -->
  <xsl:if test="$hour &lt; 23>
    <xsl:call-template name="calendar">
      <xsl:with-param name="hour" select="$hour + 1"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

-and that calls an <xsl:template match="event"> when an event with the
right time is found - assuming <event>s contain <time>s which contain
<hour>s.

half hours, etc are more difficult; something with minute & interval
params would do it ...

you may find the XSL FAQ - http://freespace.virgin.net/b.pawson/ -
helpful if you haven't seen it, though afaik it doesn't cover exactly
this question.

-- 

cheers

phil

"I have remarked very clearly that I am often of one opinion
when I am lying down and of another when I am standing up ..."

Re: Best approach to display calendar

Posted by Thomas Poe <to...@peoplepc.com>.
Hello Steve:  On your Calendar project, it seems to me, each cell in the
table receives an "event", even if no "content" is present.  Is it too
awkward to show the entire day with each view?  If not, maybe you could
create your own  "empty" tags as a default.  Just a thought, Tom
----- Original Message -----
From: "Steve Belt" <sb...@velos.com>
To: <co...@xml.apache.org>
Sent: Tuesday, February 29, 2000 11:28 AM
Subject: Best approach to display calendar


> Hello:
>
> First, I'd like to say how much I am impressed with Cocoon. I really wowed
> some people in my company when I showed them how Cocoon could feed the
same
> XML to both a web browser and a WAP device (Nokia Emulator), reformatted
for
> each.
>
> I am trying to use Cocoon to display a calendar using an XML provided by
my
> database. I would like to display the events, in HTML, formatted as you
see
> in most scheduling applications (Table listing all hours of the day, then
> showing events, if any, in the adjoining cell). I can create an XSL which
> will create a table row for each event, however, I do not know how I can
> display hours and cells which have no events to them. The XSL examples I
can
> find, in a manner of speaking, are "triggered" by elements in the XML; I,
on
> the other hand, need to display tags
>
> As I read through the documentation on Cocoon, I see several possible
> choices:
>
>  I could manipulate my XML to match my calendar - ie, include nodes for
> hours that do not have events. However, this makes my XML less generic.
>
> I could use XSP to manipulate the original XML to insert the empty nodes,
> but I am not fluent in XSP, and am having trouble seeing how to do this.
>
> Finally, perhaps this can all be handled by the XSL. However, as you can
no
> doubt tell, I still have much to learn, and I cannot find any examples
which
> show me how to accomplish this. Also, I want to be able to change my time
> intervals - ie 1-cell/hour, or 1-cell/half-hour, etc
>
> So, as I started out saying, I want to use Cocoon to provide this page.
> Anybody have any suggestions on how I should proceed? Which of Cocoon's
> technologies should I be concentrating on? Any example source code (I saw
> Jetspeed, but They are using Turbine)?
>
> Thanks in Advance,
>
> Steve
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>