Monday, April 13, 2026

OIC - Handling Multiple Stub & Payment Matching in XSLT (OIC Optimization)

๐Ÿš€ Handling Multiple Stub & Payment Matching in XSLT (OIC Optimization)

๐Ÿ“Œ Problem Context

We receive:

Multiple StubRecords

Multiple PaymentRecords

Same Transaction Number across records

๐Ÿ‘‰ Goal:

Correctly match multiple stubs with multiple payments

Ensure accurate mapping

Avoid 120 sec XSLT timeout

⚠️ Issue with Traditional Matching

XML

//ns25:PaymentRecord[ns25:TransactionNumber = $txn]

❌ Fetches all records

❌ Incorrect matching

❌ Slow → Timeout

✅ Optimized Steps Using xsl:key

๐Ÿ”‘ Step 1: Define Keys

XML

<xsl:key name="stubKey"

         match="ns25:StubRecord"

         use="concat(ns25:TransactionNumber,'|',ns25:OperatorID)"/>


<xsl:key name="payKey"

         match="ns25:PaymentRecord"

         use="concat(ns25:TransactionNumber,'|',normalize-space(ns25:Filler3))"/>


<xsl:key name="payKeyExact"

         match="ns25:PaymentRecord"

         use="concat(ns25:TransactionNumber,'|',normalize-space(ns25:Filler3),'|',ns25:PaymentAmount)"/>

๐Ÿ”„ Step 2: Loop Through Stub Records

XML

<xsl:for-each select="$ReadSourceFile/.../ns25:StubRecord">

๐Ÿงฎ Step 3: Extract Values

XML

<xsl:variable name="txn" select="ns25:TransactionNumber"/>

<xsl:variable name="op" select="ns25:OperatorID"/>

<xsl:variable name="amt" select="ns25:PaidAmount"/>

๐Ÿ”— Step 4: Build Composite Keys

XML

<xsl:variable name="stubKeyVal" select="concat($txn,'|',$op)"/>

<xsl:variable name="payKeyVal" select="concat($txn,'|',$op)"/>

<xsl:variable name="payKeyExactVal" select="concat($txn,'|',$op,'|',$amt)"/>

Step 5: Fetch Using Key

XML

<xsl:variable name="sameStub" select="key('stubKey',$stubKeyVal)"/>

<xsl:variable name="payments" select="key('payKey',$payKeyVal)"/>

<xsl:variable name="paymentsExact" select="key('payKeyExact',$payKeyExactVal)"/>

๐Ÿ” Step 6: Handle Multiple Stub Records

XML

<xsl:if test="count($sameStub) > 1">

๐Ÿ‘‰ Ensures:

Only process when multiple stubs exist for same transaction + operator

Avoid incorrect or duplicate mapping

๐ŸŽฏ Step 7: Choose Best Payment Match

XML

<xsl:variable name="finalPayments"

    select="if (exists($paymentsExact)) then $paymentsExact else $payments"/>

๐Ÿ‘‰ Prefer:

Exact match (txn + operator + amount)

Else fallback

๐Ÿ”„ Step 8: Map & Merge Data

XML

<xsl:value-of select="normalize-space(ns25:StubAccountNumber)"/>


<xsl:value-of select="oraext:create-delimited-string($finalPayments/ns25:ChequeNumber,'|')"/>

๐Ÿ“ค Step 9: Generate Output

๐Ÿ‘‰ One output per valid stub, enriched with matched payments

๐ŸŽฏ Final One-Line Summary

๐Ÿ‘‰ “Use xsl:key with composite keys to accurately match multiple stub and payment records for the same transaction, handle multi-stub scenarios using count logic, and ensure optimized performance to avoid XSLT timeout in OIC.”

Code Screenshots:





No comments:

Post a Comment

Featured Post

OIC - Handling Multiple Stub & Payment Matching in XSLT (OIC Optimization)

๐Ÿš€ Handling Multiple Stub & Payment Matching in XSLT (OIC Optimization) ๐Ÿ“Œ Problem Context We receive: Multiple StubRecords Multiple Pay...