tags:

views:

24

answers:

1

No doubt this will be something obvious, but the following code has 2 errors on the marked line:

<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:date="http://exslt.org/dates-and-times"
    extension-element-prefixes="date">

  <xsl:import href="date/date.xsl" />

  <xsl:template match="//day">
    <td>
      <date:day-in-month(<xsl:value-of select='@start_date' />)/> <!--problem here-->
    </td>
  </xsl:template>   
</xsl:stylesheet>

The errors are:

  • Tag missing closing bracket '>'
  • Missing end tag "date:day-in-month"

So far as I can see neither of those is the case. Any thoughts, or am I just blind?

+3  A: 

For starters, XSLT must always be valid XML. Yours clearly isn't, since you nest one tag inside another. This is your first clue that you do something wrong.

Second, date:day-in-month is an XPath function, not an element, and therefore must be used in an XPath expression. The latter can, for example, be a value of xsl:value-of/@select attribute:

<xsl:value-of select='date:day-in-month(@start_date)' />
Pavel Minaev
Thanks very much. I'm very definitely at the beginning of the learning curve with XML. Seeing the explanation as well as the solution is very helpful.
dnagirl