Subject: Re: [xsl] XML subset selection-a simpler way? From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Fri, 09 Jun 2006 10:10:53 +0100 |
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" />
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>).
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); }
Jeni -- Jeni Tennison http://www.jenitennison.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XML subset selection-a simple, Alan Varga | Thread | [xsl] Copy part of the file if some, brigadasinter@xxxxxx |
Re: [xsl] url encoding gets wrong w, andrew welch | Date | RE: [xsl] url encoding gets wrong w, Michael Kay |
Month |