Retrieving the Previous Node Value in OIC XSLT: Ensuring RT Records Have D1 as the Previous Record
Use Case: RT Record Validation in Oracle Integration Cloud (OIC)
In Oracle Integration Cloud (OIC), performing sequence-based validation in XML transformations is essential to maintain data integrity. One such scenario requires verifying that every RT record is immediately preceded by a D1 record.
Validation Rules:
- If a record starts with
"RT"
, the immediately preceding record must start with"D1"
. - If an
"RT"
record does not have a preceding"D1"
, a structure validation error will be thrown to ensure data correctness.
This validation helps enforce the required sequence before further processing, preventing incorrect or incomplete data from being processed in OIC.
Json used for writing a validation messages using stage:
{
"Validation" : [{
"Message" : "XXXXXXXXXXXX"
}]
}
Solution steps:
- For each record
- Check if it is record starting with RT. substring(ns:23FileData, 1,2) = 'RT'
- Check the preceding node not starting with D1, substring ($ReadRawSourceFile/nsmpr0:Read Response/ns23:FileRowSet/ns23:FileRow[(ns23:FileData = current()/ns23:FileData)]/preceding-sibling::ns23:FileRow[1.0]/ns23:FileData, 1, 2) !="D1"
- validation error message: dvm:lookupValue("File_Validation", "key","V25","ValidarionMessage","Invalid File")
Detailed screenshots:
Similarly, to get next sibling node. We can use below xslt construct.
"following-sibling::*[1]"