4 Replies Latest reply on May 25, 2005 3:30 PM by 435237

    problem with ora:addChildNode()

    426116
      Hi,
      in wsdl file i have such a xml element defined
      ....
      <types>
      <schema attributeFormDefault="qualified" elementFormDefault="qualified"
      targetNamespace="http://ntu.ac.uk/bpel/travelagency/"
      xmlns="http://www.w3.org/2001/XMLSchema">
      ...
      <element name="intArray">
      <complexType>
      <sequence>
      <element name="ind" type="int" maxOccurs="unbounded" />
      </sequence>
      </complexType>
      </element>
      </schema>
      </types>

      when i try to add a new element to intArray i get fault message that there is an error in xpath query while executing ora:addChildNode(bpws:getVariableData('sortedIndexes','/tns:intArray'), bpws:getVariableData('no-of-results'))

      Here are fragments of my bpel file
      ...
      <variable name="no-of-results" type="xsd:int"/>
      <variable element="tns:intArray" name="sortedIndexes"/>
      ...

      <copy>
      <from expression="ora:addChildNode(bpws:getVariableData('sortedIndexes','/tns:intArray'), bpws:getVariableData('no-of-results'))"></from>
      <to variable="sortedIndexes" query="/tns:intArray"/>
      </copy>
      where tns is "http://ntu.ac.uk/bpel/travelagency/"

      Why ora:addChildNode() is not able to add new element to array of integers? Mayby I use it in wrong way? Do you have any suggestions?
        • 1. Re: problem with ora:addChildNode()
          438892
          I bet 'no-of-results' is a simple data type and not actually an xml element (while in theory I think BPEL is supposed to treat everything as xml, I bet it is not.)

          Try creating a simple xsd that has no-of-results as an element of type int.

          I have used addChildNode a bucnh and it has worked, but I have always been working with complex data structures.

          Greg
          • 2. Re: problem with ora:addChildNode()
            426116
            Thanks for a tip Greg, it helped.
            • 3. Re: problem with ora:addChildNode()
              20627
              Hi Jedrzej,

              Please don't use the addChildNode() function, this function is going to deprecated, instead use the new bpel extension insert/append (bpelx:append):

              Syntax:
              <bpel:assign>
              <bpelx:append>
              <bpelx:from ... />
              <bpelx:to ... />
              </bpelx:append>
              </bpel:assign>

              The from-spec within <append> yields a single node or a node list. (Please note: the from-spec of <bpel:copy> still MUST yield ONLY one node.) The node list will be appended as child nodes to the target node specified by to-spec. If the from-spec yields zero node, "bpel:selectionFailure" fault will be generated.

              The to-spec MUST yield one single L-Value element node. Otherwise, "bpel:selectionFailure" fault will be generated. The to-spec cannot refer to a partnerLink.

              See: http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Node.html#appendChild(org.w3c.dom.Node)

              Example: (XSD details at end of the document)

              Consolidating multiple bills of material into one single bill of material by appending multiple "b:part" for one BOM to "b:parts" the consolidated BOM.
              -----------------------
              <bpel:assign>
              <bpelx:append>
              <from variable="billOfMaterialVar"
              query="/b:bom/b:parts/b:part" />
              <to variable="consolidatedBillOfMaterialVar"
              query="/b:bom/b:parts" />
              </bpelx:append>
              </bpel:assign>
              -----------------------

              2. Insert
              2.1 insertBefore
              Syntax:
              <bpel:assign>
              <bpelx:insertBefore>
              <bpelx:from ... />
              <bpelx:to ... />
              </bpelx:insertBefore>
              </bpel:assign>

              The restriction and semantics of from-spec under insertBefore is similar to those in the case of <bpelx:append>.

              The to-spec under <insertBefore> MUST points to one or more single L-Value nodes. If more than one nodes are returned, the first node will be used as the reference node. The reference node MUST be an element node. The parent of the reference node MUST be an element node also. Otherwise, "bpel:selectionFailure" fault will be generated. The to-spec cannot refer to a partnerLink.

              The node list generated by the from-spec will be inserted before the reference node.

              See:
              http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Node.html#insertBefore(org.w3c.dom.Node,%20org.w3c.dom.Node)

              Example: (XSD details at end of the document)

              Say before the execution of <insertBefore>, the value of "addrVar" is:
              ----------------------
              <a:usAddress>
              <a:state>CA</a:state>
              <a:zipcode>94065</a:zipcode>
              </a:usAddress>
              ----------------------

              After the execution of the following:
              ----------------------
              <bpel:assign>
              <bpelx:insertBefore>
              <from>
              <a:city>Redwood Shore></a:city>
              </from>
              <to "addrVar" query="/a:usAddress/a:state" />
              </bpelx:insertBefore>
              </bpel:assign>
              ----------------------

              The value of "addrVar" becomes:
              ----------------------
              <a:usAddress>
              <a:city>Redwood Shore</a:city>
              <a:state>CA</a:state>
              <a:zipcode>94065</a:zipcode>
              </a:usAddress>
              ----------------------


              2.2 insertAfter
              Syntax:
              <bpel:assign>
              <bpelx:insertAfter>
              <bpelx:from ... />
              <bpelx:to ... />
              </bpelx:insertAfter>
              </bpel:assign>

              <insertAfter> is very similar to <insertBefore>. Except:

              If more than one L-Value nodes are returned by the to-spec, the last node will be used as the reference node.
              Instead of inserting nodes "before" the reference node, the source nodes will be inserted after the "reference" node.

              This operation can also be considered a macro of conditional-switch + (append or insertBefore).


              Example: (XSD details at end of the document)

              Say before the execution of <insertAfter>, the value of "addrVar" is:
              ----------------------
              <a:usAddress>
              <a:addressLine>500 Oracle Parkway</a:addressLine>
              <a:state>CA</a:state>
              <a:zipcode>94065</a:zipcode>
              </a:usAddress>
              ----------------------

              After the execution of the following:
              ----------------------
              <bpel:assign>
              <bpelx:insertAfter>
              <from>
              <a:addressLine>Mailstop 1op6</a:addressLine>
              </from>
              <to "addrVar" query="/a:usAddress/a:addressLine[1]" />
              </bpelx:insertAfter>
              </bpel:assign>
              ----------------------

              The value of "addrVar" becomes:
              ----------------------
              <a:usAddress>
              <a:addressLine>500 Oracle Parkway</a:addressLine>
              <a:addressLine>Mailstop 1op6</a:addressLine>
              <a:state>CA</a:state>
              <a:zipcode>94065</a:zipcode>
              </a:usAddress>
              ----------------------

              • 4. Re: problem with ora:addChildNode()
                435237
                Does anyone know where (or if) there is a document illustrating what is deprecated for a particular release? Is that in the release notes (my first quick perusal didn't see anything obvious)?

                Thanks for the help,
                -Dustin