Saturday, July 7, 2012

Some Facts for converting xsl:for-each-group to xsl:for-each


XSLT 2.0 has provided many new features out of which one is of <xsl:for-each-group> defined as:

---------------------------------------------------------------
<xsl:for-each-group
  select = expression
  group-by? = expression
  group-adjacent? = expression
  group-starting-with? = pattern
  group-ending-with? = pattern
  collation? = { uri }>
</xsl:for-each-group>

---------------------------------------------------------------
In SOA 11g I have faced such an issue where <xsl:for-each-group> was not getting executed and producing errors. For such scenarios we need to convert the <xsl:for-each-group> to <xsl:for-each> of version 1.0. Hence some logic has been implemented for this conversion.

We can try to implement this conversion by Implementation of a Key based on some of the Common_Id's like some ID/Number. By this we can implement the logic of group-by function.

The main element used in this implementation if <xsl:key>

The pseudo code for implementing the logic is like:
---------------------------------------------------------------
<xsl:key
name="<<KEY_NAME>>"
match="<<Element_Match>>"
use="<<Common_ID>>"/>

---------------------------------------------------------------
<xsl:for-each select="key('<<KEY_NAME>>','<<Common_ID>>')">
    <xsl:value-of select="<<Common_ID>>"/>
    <xsl:value-of select="<<Element_Value>>"/>
</xsl:for-each>

---------------------------------------------------------------

Feedback and comments provided will be very beneficial.

Thanks.

                 www.w3schools.com/xsl/

B2B Features with OIC

During last couple of months various new features are getting introduced in Oracle Integration Cloud, out of those there is a new feature f...