You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Perry Molendijk <xi...@iinet.net.au> on 2003/05/07 17:38:14 UTC

FYI: Date Input Module and date formatting

Blank
 For anyone trying to come to grips with input modules. Below is what you
need to do if you want to make the current date in a particular format
available in the sitemap:

in cocoon.xconf look for:

<component-instance
class="org.apache.cocoon.components.modules.input.DateInputModule"
logger="core.modules.input" name="date"/>

and replace it with:

<component-instance
class="org.apache.cocoon.components.modules.input.DateInputModule"
logger="core.modules.input" name="date">
  <au-format>dd-EEE-yyyy</au-format>
  <us-format>MM-dd-yyyy</us-format>
  <format>EEE, MMM d, yyyy</format>
  <long-format>EEE, d MMM yyyy HH:mm:ss Z</long-format>
</component-instance>

in the sitemap snippet below is an example of passing the current date as a
parameter to an XSL:

<map:match pattern="**.pdf">
  <map:generate src="xdocs/{1}.xml"/>
  <map:transform src="stylesheets/xmlToFo.xsl">
  <map:parameter name="currentDate" value="{date:format}"/>
  </map:transform>
  <map:serialize type="fo2pdf"/>
</map:match>

You can replace {date:format} with {date:xxxxx} where xxxxx represents the
name of one of the tags added in cocoon.xconf.
e.g. {date:long-format} will give you a date in "EEE, d MMM yyyy HH:mm:ss Z"
format.

>From an error message I worked that the date input module must somehow use
the SimpleDateFormat, so for more information about the date formats
supported see the Java JDK docs on docs/api/java/text/SimpleDateFormat.html.

Thanks to Christian Haul for getting me on the right track.

Perry


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