2 Replies Latest reply: Dec 13, 2011 4:03 AM by Neeraj Sehgal RSS

    Using XSLT Group By and XSLT 2.0 in SOA Suite Components

    765320
      Hi All,
      I have requirement of grouping the XML structure according to the Node value present in XML structure.

      I need to model the XSLT as mentioned in the following post

      http://stackoverflow.com/questions/2146648/how-to-apply-group-by-on-xslt-elements

      This is called Muenchian grouping algorithm for grouping. When I tried to implement the same using the XSLT mapper(Not XSLT); I got following errors

      Line Number:(20) : Error: "xsl:output" XSL Element Currently not Supported
      Line Number:(22) : Error: "xsl:key" XSL Element Currently not Supported
      Line Number:(26) : Error: "xsl:for-each-group" XSL Element Currently not Supported

      I think Oracle XSLT processor is not supporting the XSLT element required to implement the Grouping algo.

      Next Step; I created XSLT containing the Grouping logic. When I used the same in Mediator(The file in XSLT 2.0 and not the XSL Mapper file generated by Jdeveloper Ide)
      in Static Routing Rule > Transform Using

      I am getting following Runtime error

      JCABinding=> XXXService XXXServiceAdapter Service XXXService was unable to perform delivery of inbound message to the composite default/JapanPOProcessor!1.0*soa_7a60ac21-2750-4ba3-9670-27c160c5c8ff due to: oracle.tip.mediator.infra.exception.MediatorException: ORAMED-03601:[Invalid transformer configuration]Unable to create transformer. It could be because of transformation file or configuration issues. Reason : "xsl/GeneratePOGroupCollection.xsl"Possible Fix:Check log file for any exceptions and contact Oracle Support Services for further help.

      I think only XSLT Mapper file is supported for Transformation.

      Now my question is how to use the above .xsl file which containing Grouping logic; in order to transform the XML.

      1] Using Java Callout and using the Oracle XML SDK/JAXP API to call the Java logic to transform. Can oracle XML V2 parser supports for XSLT 2.0?

      2] Can I use above XSLT using the BPEL function ??
      ora:processXSLT('XXXX.xsl',bpws:getVariableData('inputVariable','payload'))"
      Above construct is not supported in Mediator. Its only available for BPEL Components.

      3] java callout in BPEL?

      Let me know the implementation approach.If possible explain the same with example if any.
        • 1. Re: Using XSLT Group By and XSLT 2.0 in SOA Suite Components
          765320
          Any updates on this issue?

          Sushil
          • 2. Re: Using XSLT Group By and XSLT 2.0 in SOA Suite Components
            Neeraj Sehgal
            Hi Sushil,

            I had a similar kind of grouping requirement and I used xsl:for-each and xsl:key to accomplish the same. It worked.

            Also you can ignore the XSLT errors you get, just make sure you write the code in source and do not switch over from Source to Design.

            You can modify the following code to cater to your requirement.

            Each Employee can work in multiple Departments. The following code shows which all departments each employee works in (so group by employee). I've removed the namespaces to improve the readability

            Source XML
            <?xml version="1.0" encoding="UTF-8" ?>
            ...
               <P_RETURN_CUR>
                  <P_RETURN_CUR_Row>
                     <ENAME>Neeraj</ENAME>
                     <DEPT>ORACLE</DEPT>
                  </P_RETURN_CUR_Row>
                  <P_RETURN_CUR_Row>
                     <ENAME>John</ENAME>
                     <DEPT>ORACLE</DEPT>
                  </P_RETURN_CUR_Row>
                  <P_RETURN_CUR_Row>
                     <ENAME>Neeraj</ENAME>
                     <DEPT>MANUFACTURING</DEPT>
                  </P_RETURN_CUR_Row>
                  <P_RETURN_CUR_Row>
                     <ENAME>Julie</ENAME>
                     <DEPT>FINANCE</DEPT>
                  </P_RETURN_CUR_Row>
                  <P_RETURN_CUR_Row>
                     <ENAME>Julie</ENAME>
                     <DEPT>MANUFACTURING</DEPT>
                  </P_RETURN_CUR_Row>
                  <P_RETURN_CUR_Row>
                     <ENAME>Bourne</ENAME>
                     <DEPT>FINANCE</DEPT>
                  </P_RETURN_CUR_Row>
                  <P_RETURN_CUR_Row>
                     <ENAME>Claire</ENAME>
                     <DEPT>MANUFACTURING</DEPT>
                  </P_RETURN_CUR_Row>
                  <P_RETURN_CUR_Row>
                     <ENAME>Claire</ENAME>
                     <DEPT>FINANCE</DEPT>
                  </P_RETURN_CUR_Row>
               </P_RETURN_CUR>
            </OutputParameters>
            Target XML
            <?xml version = '1.0' encoding = 'UTF-8'?>
            ......
               <ns0:Employee>
                  <ns0:Name>Bourne</ns0:Name>
                  <ns0:Depts>
                     <ns0:DeptName>FINANCE</ns0:DeptName>
                  </ns0:Depts>
               </ns0:Employee>
               <ns0:Employee>
                  <ns0:Name>Claire</ns0:Name>
                  <ns0:Depts>
                     <ns0:DeptName>FINANCE</ns0:DeptName>
                     <ns0:DeptName>MANUFACTURING</ns0:DeptName>
                  </ns0:Depts>
               </ns0:Employee>
               <ns0:Employee>
                  <ns0:Name>John</ns0:Name>
                  <ns0:Depts>
                     <ns0:DeptName>ORACLE</ns0:DeptName>
                  </ns0:Depts>
               </ns0:Employee>
               <ns0:Employee>
                  <ns0:Name>Julie</ns0:Name>
                  <ns0:Depts>
                     <ns0:DeptName>FINANCE</ns0:DeptName>
                     <ns0:DeptName>MANUFACTURING</ns0:DeptName>
                  </ns0:Depts>
               </ns0:Employee>
               <ns0:Employee>
                  <ns0:Name>Neeraj</ns0:Name>
                  <ns0:Depts>
                     <ns0:DeptName>MANUFACTURING</ns0:DeptName>
                     <ns0:DeptName>ORACLE</ns0:DeptName>
                  </ns0:Depts>
               </ns0:Employee>
            </ns0:EmpDetails>
            Code
            <?xml version="1.0" encoding="UTF-8" ?>
                            .....
            
                            xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
                            exclude-result-prefixes="xsi xsl db xsd ns0 xp20 bpws aia mhdr bpel2 oraext dvm hwf med ids bpm xdk xref ora socket ldap">
              <xsl:key match="db:P_RETURN_CUR_Row" name="depts_of_employee" use="db:ENAME"/>
              <xsl:template match="/">
                <ns0:EmpDetails>
                  <xsl:for-each select="/db:OutputParameters/db:P_RETURN_CUR/db:P_RETURN_CUR_Row[count(. | key('depts_of_employee', db:ENAME)[1]) = 1]">
                    <xsl:sort select="db:ENAME"/>
                    <ns0:Employee>
                      <ns0:Name>
                        <xsl:value-of select="db:ENAME"/>
                      </ns0:Name>
                      <ns0:Depts>
                        <xsl:for-each select="key('depts_of_employee', db:ENAME)">
                          <xsl:sort select="db:DEPT"/>
                          <ns0:DeptName>
                            <xsl:value-of select="db:DEPT"/>
                          </ns0:DeptName>
                        </xsl:for-each>
                      </ns0:Depts>
                    </ns0:Employee>
                  </xsl:for-each>
                </ns0:EmpDetails>
              </xsl:template>
            </xsl:stylesheet>
            Hope it helps.....

            Regards,
            Neeraj Sehgal