Wednesday, March 26, 2025

OIC - Adjusting Dates in XML Transformations Using XSD Date Functions

Use Case:

In enterprise integrations, especially in Oracle Integration Cloud (OIC) or other XML-based transformation engines, there is often a need to manipulate date values dynamically. One such scenario is adjusting a business date by subtracting or adding a specific duration.

For instance, an XML payload may contain a business date, and a downstream system requires processing based on the previous day's date. The transformation logic should ensure the correct date adjustment while maintaining XML schema compliance.

Solution Steps:

  1. Identify the Input Field:

    • The source XML contains a BusinessDate field under the request-wrapper node.
    • The XPath expression to access this field is:
      /nstrgmpr:execute/ns20:request-wrapper/ns20:BusinessDate
      
  2. Apply the XSD Date Function:

    • To ensure that the extracted value is interpreted correctly as a date, we use the xsd:date() function.
    • This ensures type safety in XML transformations.
    • It supports value as YYYY-MM-DD or YYYY-MM-DDZ
  3. Subtract One Day from the Business Date:

    • The xsd:dayTimeDuration("P1D") function represents a one-day duration.
    • Using the subtraction operator (-), we deduct one day from the business date.
  4. Final Transformation Expression:

    • This expression dynamically computes the previous day’s date from the given BusinessDatexsd:date(/nstrgmpr:execute/ns20:request-wrapper/ns20:BusinessDate) - xsd:dayTimeDuration("P1D")
  5. Integrate the Expression in OIC or XSLT Transformations:

    • This logic can be used in XSLT mappings, Oracle Integration Cloud (OIC) expressions, or any XML transformation engine that supports XSD functions.

Screenshot:



No comments:

Post a Comment

Featured Post

Types of encryption techniques

There are several types of encryption techniques used to secure data, each with its own use case and strengths: 1. Symmetric Encryption Us...