I'd said of Roy Wood's multiRef situation that

>If it's always going to be that way, with the data being in "item" tags
>which are
>actually siblings, and no "item" tags which aren't your data, perhaps
>something like
>  var soapResponse = soapCall.invoke();
> // deal with fault issues, return if needed
>  var node= soapResponse.message.getElementsByTagName("item")[0]; //
>first item.
>  var res=node.nodeValue;
>  while(null!=(node=node.nextSibling))res+=node.nodeValue;
>  return res;

and he replies

Hmm, this is really close.  I'm just grabbing the whole array of "item"
matches, rather than the first one, and then iterating through them.  I
end up with the right number of matches, but Mozilla seems to think each
element has empty data.
oops...try replacing node.nodeValue with node.firstChild.nodeValue, or
rather, for debugging purposes, with
  new XMLSerializer().serializeToString(node);
and look at the XML you've got; the nodeValue is the value of the text
node which is the first child of of the "item", unless the text value is
too big in which case it may be broken up and you get more text children
of the "item" and you gotta loop through them all.

However, there's another issue: you have to be really sure that the "item"
values are always gonna be not only in order but a complete set. If you
SOAPify a vector constructed via
  Vector V = new Vector();
  V.add(a); V.add(b); V.add(a);
that's a vector of length 3, but you may end up with a multiref object
containing 3 refs to 2 values, and if that kind of issue can arise in
your app, which is not obvious to me but could be a worry, then I
think you might need to do something like
  var mRefTable=new Object();
  { var mRefs=soapResponse.message.getElementsByTagName("multiRef");
    for(var i=0;i<mRefs.length;i++){
      var mRef=mRefs[i];
      mRefTable[mRef.id]=mRef;
      }
  }
and after that you can use mRefTable to find the href="#..." values
throughout soapResponse.message; well, I admit I'm posting this
in the hopes that somebody will see the flaw, if there is one. My
confidence is not hugely high, but something resembling this should
be okay. On the other hand, if you do have a reliable item-sequence
to work with you may not have to think about an mRefTable at all.

Tom Myers


Reply via email to