Hi Alan,
My question for this list is: Is there a simpler way than what I am
doing now to narrow down the events I want to use? It works just fine,
but it took a lot of setup.
1) I have an HTML form with a submit button and two listboxes, one for
calendar style (by band or by month), the other to choose either the
band name or the month name.
2) The submit button stores cookies with the values of each of the
listboxes, then reloads the page.
3) When the page reloads, an onload script checks the cookies and builds
an XSL filename.
4) The main XSL defines an xsl:variable corresponding to values of the
cookies, and also has 2 xsl:includes.
5) One of the xsl:includes contains the bulk of the templates, the other
only contains a template with a <tbody> element which does the actual
selection of events (select="Event[MonthName=$month]).
It sounds as though you could be using stylesheet parameters. If you
have a stylesheet like:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="calendar-style" select="'by-month'" />
<xsl:param name="band" />
<xsl:param name="month" />
...
</xsl:stylesheet>
then you can pass values for those parameters into the stylesheet prior
to the transformation.
What I'd do is have the 'submit' button invoke a function that set the
stylesheet parameters based on the values in the list boxes, and then
performed the transformation, loading the result into a portion of your
page (a <div>).
In Sarissa, it's something like the following (completely untested and
partially pseudo- code):
function reloadCalendar() {
// Set the processor parameters based on the values given in the form
processor.setParameter(null, 'calendar-style', form.calendarStyle);
if (form.calendarStyle == 'by-band') {
processor.setParameter(null, 'band', form.name);
} else {
processor.setParameter(null, 'month', form.name);
}
// Transform the XML to produce an HTML calendar
htmlCalendar = processor.transformToDocument(xmlCalendar);
// Replace the existing calendar with the new one
calendarDiv.innerHTML =
new XMLSerializer.serializeToString(htmlCalendar);
}
The above function relies on a global 'processor' variable that is an
XSLTProcessor with your parameterised stylesheet imported, and a global
'xmlCalendar' variable that holds the DOMDocument representing the XML
source document. These each only need to be set once, and can be reused
again and again, which should make your whole application that much quicker.
I hope that gives you enough pointers.
Cheers,
Jeni
--
Jeni Tennison
http://www.jenitennison.com
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--