Static website for local motocross track (circa Jun 2004)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

65 lines
2.8 KiB

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:x="http://www.w3.org/1999/xhtml" exclude-result-prefixes="x">
  4. <xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/>
  5. <xsl:key name="entry_list" match="x:tr[x:td[2][@align][not(. = 'Number')]]"
  6. use="preceding-sibling::x:tr[x:td[1][not(@align)][not(. = 'Race Results')]][1]/x:td[1]"/>
  7. <xsl:variable name="entries" select="count(//x:tr[x:td[2][@align][not(. = 'Number')]])"/>
  8. <xsl:variable name="classes" select="count(//x:tr[x:td[1][not(@align)][not(. = 'Race Results')]])"/>
  9. <xsl:template match="/">
  10. <xsl:apply-templates select="//x:table"/>
  11. </xsl:template>
  12. <xsl:template match="x:table">
  13. <xsl:element name="race">
  14. <xsl:attribute name="date"><xsl:value-of select="x:tr[3]/x:th[1]"/></xsl:attribute>
  15. <xsl:attribute name="name"><xsl:value-of select="x:tr[2]/x:th[1]"/></xsl:attribute>
  16. <xsl:attribute name="entries"><xsl:value-of select="$entries"/></xsl:attribute>
  17. <xsl:attribute name="classes"><xsl:value-of select="$classes"/></xsl:attribute>
  18. <xsl:call-template name="class_handler">
  19. <xsl:with-param name="class_list" select="x:tr/x:td[1][not(@align)][not(. = 'Race Results')]"/>
  20. </xsl:call-template>
  21. </xsl:element>
  22. </xsl:template>
  23. <xsl:template name="class_handler">
  24. <xsl:param name="class_list"/>
  25. <xsl:for-each select="$class_list">
  26. <xsl:element name="class">
  27. <xsl:attribute name="name"><xsl:value-of select="."/></xsl:attribute>
  28. <xsl:call-template name="class_entries">
  29. <xsl:with-param name="entries" select="key('entry_list', . )"/>
  30. </xsl:call-template>
  31. </xsl:element>
  32. </xsl:for-each>
  33. </xsl:template>
  34. <xsl:template name="class_entries">
  35. <xsl:param name="entries"/>
  36. <xsl:for-each select="$entries">
  37. <xsl:sort select="x:td[1]" data-type="number" lang="C"/>
  38. <xsl:element name="entry">
  39. <xsl:attribute name="name"><xsl:value-of select="x:td[5]"/></xsl:attribute>
  40. <xsl:attribute name="from"><xsl:value-of select="x:td[6]"/></xsl:attribute>
  41. <xsl:element name="bike">
  42. <xsl:attribute name="brand"><xsl:value-of select="x:td[3]"/></xsl:attribute>
  43. <xsl:attribute name="number"><xsl:value-of select="x:td[2]"/></xsl:attribute>
  44. </xsl:element>
  45. <xsl:element name="moto1">
  46. <xsl:attribute name="finish"><xsl:value-of select="x:td[7]"/></xsl:attribute>
  47. </xsl:element>
  48. <xsl:element name="moto2">
  49. <xsl:attribute name="finish"><xsl:value-of select="x:td[8]"/></xsl:attribute>
  50. </xsl:element>
  51. <xsl:element name="overall">
  52. <xsl:attribute name="finish"><xsl:value-of select="x:td[1]"/></xsl:attribute>
  53. <xsl:attribute name="points"><xsl:value-of select="x:td[11]"/></xsl:attribute>
  54. </xsl:element>
  55. </xsl:element>
  56. </xsl:for-each>
  57. </xsl:template>
  58. </xsl:stylesheet>