Question

We're using Tibco BusinessWorks to pass an XML document to a Tibco BusinessEvents process. Because BusinessEvents does not have a DATE format, only DATETIME, we must change Dates in the source XML document before sending to BusinessEvents, and map the response's DateTime values back to simple Dates.

This is both annoying and cumbersome.

In an attempt to improve BusinessWorks' performance, I'm writing a stylesheet to handle the mapping. Here's what I've got.

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:inf="http:/the.company.namespace">

<xsl:template match="node()">
    <xsl:copy>
        <xsl:apply-templates select="node()" />
    </xsl:copy>
</xsl:template>

<xsl:template match="inf:PriorExpirationDate | inf:OrderDate | inf:SegmentEffectiveDate |
                    inf:SegmentExpirationDate | inf:CancelDate | inf:NewBusinessEffectiveDate |
                    inf:NewBusinessExpirationDate | inf:RenewalEffectiveDate | inf:RenewalExpirationDate |
                    inf:QuestionDate | inf:ViolationDate | inf:ConvictionDate |
                    inf:EffectiveDate | inf:RatingDate | inf:AdvanceDate |
                    inf:SIDRevisionDate | inf:DriverLicensedDate |
                    inf:ESignatureDate | inf:UploadDate | inf:CancelDate |
                    inf:CancelProcessedDate | inf:CancelEffectiveDate | inf:CreatedDate |
                    inf:QuoteCreationDate | inf:QuoteModifiedDate | inf:QuoteExpirationDate |
                    inf:RateStartDate | inf:RateEndDate | inf:ChangeEffectiveDate | inf:PostDate |
                    inf:EffectiveDate | inf:ExpirationDate | inf:BirthDate |
                    inf:InstallmentDueDate | inf:CommercialDriverLicenseDate ">
    <xsl:element name="{name()}">
        <xsl:value-of
            select="concat(format-date(text(),'[Y0001]-[M01]-[D01]'), 'T00:00:00')" />
    </xsl:element>
</xsl:template>

While functional, this not ideal. I'd prefer NOT to have to enumerate each element I need transformed, I'd rather specify a TYPE that needs to be converted.

(1) Does XSL offer this functionality ?

(2) Alternatively, there are some element names that may be DATEs in one location and DATETIMEs in others. Is there an efficient way of excluding some DATETIME elements if I know the parent by name ?

(3) Lastly, does anyone see room for enhancement beyond the scope of the question ?

Some context: The original mapping is done inside BusinessWorks' editor, where the GUI generates its own mapping file, a several-hundred-line series of if/then/else statements. For a 50k document (our average) this amounts to nearly 20ms overhead per transformation for a web service that completes its actual work in fewer than 50ms. This is the bottleneck that must be improved upon.

Was it helpful?

Solution

Just use:

<xsl:template match="*[. castable as xs:date]">
 <!-- Your code here -->
</xsl:template>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top