4 Replies Latest reply: Jan 23, 2014 12:11 PM by WP v.2 RSS

    Accessing element from an array of elements based on attribute value

    WP v.2

      Hi All,

       

      I'm creating a BPEL 11g process that calls a web service which returns an array of data. I need to iterator over the data and access elements based on their attribute value.

       

      Here is an example payload from the web service:

       

      <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
         <env:Header/>
         <env:Body>
            <OutputParameters xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.oracle.com/apps/inv/soaprovider/plsql/item_pub/get_item/">
               <GET_ITEM>
                  <Row>
                     <Column name="ORGANIZATION_ID" sqltype="NUMBER">101</Column>
                     <Column name="ORGANIZATION_CODE" sqltype="VARCHAR2">MyOrg</Column>
                     <Column name="SEGMENT1" sqltype="VARCHAR2">MySegment</Column>
                     <Column name="DESCRIPTION" sqltype="VARCHAR2">Upload 445</Column>
                     <Column name="PRIMARY_UNIT_OF_MEASURE" sqltype="VARCHAR2">Each</Column>
                     <Column name="PRIMARY_UOM_CODE" sqltype="VARCHAR2">EA</Column>
                     <Column name="ITEM_CREATION_DATE" sqltype="VARCHAR2">01/21/2014 09:22:35</Column>
                     <Column name="ITEM_UPDATE_DATE" sqltype="VARCHAR2">01/21/2014 09:22:35</Column>
                     <Column name="REVISION" sqltype="VARCHAR2">0</Column>
                     <Column name="REVISION_LABEL" sqltype="VARCHAR2">0</Column>
                     <Column name="REV_CREATION_DATE" sqltype="VARCHAR2">01/21/2014 09:22:57</Column>
                     <Column name="REV_UPDATE_DATE" sqltype="VARCHAR2">01/21/2014 09:22:57</Column>
                  </Row>
                  <Row>
                     ...
                  </Row>
                  <Row>
                     ...
                  </Row>
               </GET_ITEM>
            </OutputParameters>
         </env:Body>
      </env:Envelope>
      

       

      How can I pick out certain columns based on the column's name attribute?

       

      I tried doing this:

       

      bpws:getVariableData('getItemResponse','body','/ns7:OutputParameters/ns7:GET_ITEM/ns7:Row[$partIndex]/ns7:Column[@name='SEGMENT1'])
      

       

      and

       

      bpws:getVariableData('getItemResponse','body','/ns7:OutputParameters/ns7:GET_ITEM/ns7:Row[bpws:getVariableData('partIndex')]/ns7:Column[@name='SEGMENT1'])
      

       

      but got this compilation error:

       

      Error(157): xpath expression "bpws:getVariableData('getItemResponse','body','/ns7:OutputParameters/ns7:GET_ITEM/ns7:Row[bpws:getVariableData('partIndex')]/ns7:Column[@name='SEGMENT1'])" specified in  is not valid, because XPath query syntax error. The syntax error occurs while parsing XPath expression bpws:getVariableData('getItemResponse','body','/ns7:OutputParameters/ns7:GET_ITEM/ns7:Row[bpws:getVariableData('partIndex')]/ns7:Column[@name='SEGMENT1']), at position 112. The XPath query syntax was wrong; the exception was: Expected: ). Check the detailed root cause described in the exception message text and verify that the XPath expression named in the error message is correct. The XPath expression is defined in the BPEL process.

       

      I'm using JDeveloper 11.1.1.7.0

       

      Thanks in advanced,

      Bill