[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: EPUB: dbtimestamp PI in pubdate or date
Hi, currently, I'm investigating EPUB(3) and dates in pubdate. It's not unusual to have the following <pubdate> inside an info, using the default date format: <pubdate><?dbtimestamp?></pubdate> This works for HTML, FO, etc. except for EPUB. For EPUB, you get: WARNING: wrong metadata date format: '' in element bookinfo/pubdate. It must be in one of these forms: YYYY, YYYY-MM, or YYYY-MM-DD. Well, I think the message is correct as there is really no text. It doesn't help to add a "format" pseudo attribute here: <pubdate><?dbtimestamp format="Y, m d?></pubdate> This would lead to the same message. Digging deeper into the EPUB3 stylesheets, I assume the "dbtimestamp" PI isn't supported at all. The pubdate is used as OPF metadata in the following template: <xsl:template match="date|pubdate" mode="opf.metadata"> <xsl:variable name="date"> <xsl:call-template name="format.meta.date"> <xsl:with-param name="string" select="normalize-space(.)"/> </xsl:call-template> </xsl:variable> <!-- ... ---> </xsl:template> However, "format.meta.data" just checks if the given text is in the right format. If not, it displays the above warning message. Now I'm wondering if this is the right approach. 8-) Shouldn't we distinguish between two cases: 1. date or pubdate contains only text We need to check, if the text is a valid date in the format needed by EPUB 2. date or pubdate contains no text, but <?dbtimestamp?> We ignore any format pseudo attribute and return a date in the format "Y-m-d" I would propose the following change: <xsl:template match="date|pubdate" mode="opf.metadata"> <xsl:variable name="date"> <xsl:choose> <xsl:when test="processing-instruction('dbtimestamp')"> <xsl:call-template name="pi.dbtimestamp"> <xsl:with-param name="format">Y-m-d</xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:call-template name="format.meta.date"> <xsl:with-param name="string" select="normalize-space(.)"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:variable> <!-- ... ---> </xsl:template> Unfortunately, this won't work. The "pi.dbtimestamp" template doesn't allow a parameter "format". Looking into the template <xsl:variable> is used. Could we change "pi.dbtimestamp" and use <xsl:param> instead of <xsl:variable>? Or is there another solution that I can't see? What do you think? -- Gruß/Regards Thomas Schraitle
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]