You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jeff Jones <JA...@weather.com> on 2004/05/13 21:25:46 UTC

Extending ESQL - how (if at all)

Hello all.

I'd like to use XSP/ESQL to retrieve a date from a database (might be Oracle or
MySQL) in "Unix epoch" format, i.e. milliseconds since 1/1/1970. Unfortunately,
that's not a format available in java.text.SimpleDateFormat, so it doesn't seem
possible to retrieve it using the <esql:get-timestamp/> tag.

I know that this could be done with a separate XSL transform, but for
performance reasons, I'd prefer not to have to convert back to a Date object and
then back to a String representation; I'd like to work with the Date object
(actually java.sql.Timestamp) retrieved from the database.

So I've tried adding this to esql.xsl:

<xspdoc:desc>returns the value of the given column as milliseconds since the
epoch.</xspdoc:desc>
<xsl:template match
="esql:row-results//esql:get-epoch|esql:call-results//esql:get-epoch">
  <xsp:expr><xsl:call-template name="get-resultset"/>.getTimestamp
(<xsl:call-template name="get-column"/>).getTime()</xsp:expr>
</xsl:template>

And here's the part of my XSP that uses the new tag:

<process_tm><esql:get-epoch column="process_tm"/></process_tm>

A few questions:

1. Apparently I'm missing a step somewhere, because I'm just getting the
<esql:get-epoch/> tag passed straight through when the pipeline runs. (Yes,
everything else works.) I've restarted Tomcat, rebuilt the databases block, and
copied the new databases-block.jar into WEB-INF/lib, to no avail. What do I need
to do to get this change reflected in running code?

2. Am I doing this the hard way? Is there an easier solution that I'm missing?
(Remember that I really don't want to do it in a separate transform, for
performance reasons.)

3. If this actually is a worthwhile idea, how would I go about submitting it?

(Details: Cocoon 2.1.4, Tomcat 4.1.29, Sun Java 1.4.2-b28 on SuSE Linux 9.0,
kernel 2.4.21.)

Thanks in advance for any help.

</Jeff>




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org