Integrate Software AG Products Using Digital Event Services : MashZone NextGen Help : Appendix : Legacy Presto components : Mashables and Mashups : Mashups in EMML : Advanced Mashup Techniques : Converting and Working with Dates and Times : Using the ISODateFormatExt Custom XPath Function
Using the ISODateFormatExt Custom XPath Function
This custom XPath function is built into MashZone NextGen. To use the function in an XPath expression you must:
1. Declare the MashZone NextGen custom XPath namespace on <mashup> in your mashup script. For example:
<mashup name="dateExample"
xmlns="http://www.openmashup.org/schemas/v1.0/EMML"
xsi:schemaLocation="http://www.openmashup.org/schemas/v1.0/EMML
../xsd/EMMLPrestoSpec.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:fn="java:com.jackbe.jbp.jems.client.EMMLPrestoFunctions">
...
</mashup>
2. Define the to and from formats for the date or time you need to convert.
For example:
<mashup name="dateExample"
xmlns="http://www.openmashup.org/schemas/v1.0/EMML"
xsi:schemaLocation="http://www.openmashup.org/schemas/v1.0/EMML
../xsd/EMMLPrestoSpec.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:fn="java:com.jackbe.jbp.jems.client.EMMLPrestoFunctions">
<output name="result" type="document"/>
<variable name="fromFormat" type="string" default="dd/MM/yyyy"/>
<variable name="isoFormat" type="string" default="yyyy-MM-DD"/>
...
</mashup>
These formats use patterns to identify the various date or timecomponents. Some of the most common include:
Pattern
Usage
dd
Day of the month such as 05.
yyyy
Year.
MM
Numerical month.
MMM
Text month
hh
Hour in a 12-hour format (1-12).
HH
Hour in a 24-hour format (0-23).
a
AM/PM for 12-hour time formats.
mm
Minute
ss
Second
S
Millisecond
The complete list of characters and symbols that are valid inpatterns are defined in the java.text.SimpleDateFormat class. For detailedinformation, see Java API documentation for the JDK version used in yourenvironment.
3. Use the function in an XPath expression. In most cases you would use this function along with an XPath constructor function to obtain a date or time.
For example:
<mashup name="dateExample"
xmlns="http://www.openmashup.org/schemas/v1.0/EMML"
xsi:schemaLocation="http://www.openmashup.org/schemas/v1.0/EMML
../xsd/EMMLPrestoSpec.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:fn="java:com.jackbe.jbp.jems.client.EMMLPrestoFunctions">
<output name="result" type="document"/>
<variable name="fromDate" type="string" default="dd/MM/yyyy"/>
<variable name="isoDate" type="string" default="yyyy-MM-DD"/>
<invoke service="YahooRSSFeed" operation="GET"
outputvariable="$stories"/>
<sort inputvariable="$stories" sortexpr="/rss/channel/item"
sortkeys="xs:date(fn:ISODateFormatExt(pubdate, $fromFormat, $isoFormat))"
outputvariable="result" />
</mashup>
Copyright © 2017 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback