Shows page back up...
So, I've revitalized my Shows page which lists concerts and other musical engagements that I'm likely to be found at. It now has a feed. Technical details about the schema, xml and such below the fold.
[More:]
This was really just a simple proof of concept to answer the question, "Can I do semi-relational logic using just xml?". I did this in four parts:
-
I defined a Relax NG (compact) schema, that's actually pretty simple: http://josephhall.org/shows/shows.rnc.
It essentially defines a container
venueShowListwhich contains two elements,venueListandshowListwhich each contain multiplevenueandshowelements. Note: to preserve the relationality of the data model, you have to add avenueCodeContentcode for each new venue that you add to the xml file. This code is a string likeGAMHthat will then be used to identify the venue and to associate a show with a venue. -
Then I coded up all the good upcoming shows and their venues into an xml file: http://josephhall.org/shows/shows.xml.
-
Then, I had to write two xsl transforms (which takes the xml and transforms it into something else). The first transform, http://josephhall.org/shows/shows.xsl, was to take each show and put them in their own table rows in html. The second, http://josephhall.org/shows/shows-rss2.0.xsl, takes the shows and puts them into an rss 2.0 feed.
The tricky parts of these transforms were 1) being able to match a venue code from a show and then pull in parts from the
venueelement and 2) sorting the shows in terms of their dates.For 1) the trick is to save the matched
venueCodeas a variable that you can then use in XPATH for matching:<xsl:template match="@venueCode"> <xsl:variable name="ven" select="."/> <xsl:value-of select="//sh:venue[@venueCode=$ven]/sh:url"/> </xsl:template>
As for 2) the trick is to sort on parts of the
xsd:dateformat in succession (here I do this using the XSL 2.0 functions*-from-date()but you could also just find the substring and use that using XSL 1.0 substring functions):<xsl:apply-templates select="sh:show"> <xsl:sort select="year-from-date(@date)"/> <xsl:sort select="month-from-date(@date)"/> <xsl:sort select="day-from-date(@date)"/> </xsl:apply-templates>
-
Finally, I have a smarty template that pulls in the table row elements into the body of the shows.tpl file (which is called by
shows.php). That was as easy as a simple{include file="show-list.tpl"}in the shows.tpl smarty template.