1 Reply Latest reply on May 13, 2013 6:59 PM by kiransaravi

    Issue in looping over arrays, No 'part' in the variable, getElement failing

    kiransaravi
      Hi

      Hope you are doing fine
      I have a scenario where I've to loop over an array, which inturn contains another array.
      ex: inputVariable is something like this

      <Reviewer>
      <Project>
      <activities>
      ....
      ....
      </activities>
      <activities>
      ....
      ....
      </activities>
      </Project>
      <Project>
      <activities>
      ....
      ....
      </activities>
      <activities>
      ....
      ....
      </activities>
      </Project>
      </Reviewer>

      Here, Reviewer can have n number of prj's and each prj can have n number of activities.
      I normally loop and get nth element using ora:getelement(var,part,xpath,currentCounter)
      So, for projects, I did the same,
      ora:getElement('inputVariable','payload','/ns6:IndReviewer/ns6:Project',bpws:getVariableData('currProjectCounter')) -- assign it to tmpIndProjectPayload in each iteration of the loop

      But for activities within a project, i dont find the 'part'
      this is how it looks like
      ora:getElement('tmpIndProjectPayload','/ns6:IndProjectPayload/ns6:Activities',bpws:getVariableData('currPrjActivitiesCounter'))


      But this is giving me an error because the 'part' is missing here.
      Here is the error
      javax.xml.xpath.XPathExpressionException: Failed to execute getElement() function : java.lang.Double
           at oracle.xml.xpath.JXPathExpression.evaluate(JXPathExpression.java:242)
           at com.collaxa.cube.xml.xpath.BPELXPathUtil.evaluate(BPELXPathUtil.java:240)
           at com.collaxa.cube.engine.ext.bpel.common.BPELWMPHelper.evalFromValue(BPELWMPHelper.java:339)
           at com.collaxa.cube.engine.ext.bpel.v1.wmp.BPEL1AssignWMP.__executeStatements(BPEL1AssignWMP.java:137)
      ...............
      How do I resolve this
      My requirement goes 1 level even below this, as I have to iterate over Activities again, which again will miss 'part'

      Can someone help me

      Thanks in Advance
      RaviKiran
        • 1. Re: Issue in looping over arrays, No 'part' in the variable, getElement failing
          kiransaravi
          Resolved, can be helpful for someone

          <assign name="AssignIndividualActivityDetailsToTempVar">
          <copy>
          <!--<from expression="ora:getElement('tmpIndProjectPayload','IndProjectPayload','/ns6:IndProjectPayload/ns6:Activities',bpws:getVariableData('currPrjActivitiesCounter'))"/>-->
                    <from expression="bpws:getVariableData('tmpIndProjectPayload',concat('/ns6:IndProjectPayload/ns6:Activities[',bpws:getVariableData('currPrjActivitiesCounter'),']'))"/>
          <to variable="tmpIndActivityPayload"
          query="/ns6:IndActivityPayload"/>
          </copy>
          </assign>

          instead of getElement, I used something like this Array[i]

          Regards
          RaviKiran