Hi.

     First of all, i want to apologies for all the orthographic mistakes
     you'll see in this mail, i'm not realy good in english.

     Now here is my problem : In the programme i'm actualy develloping
     with xerces C++, i'm catching an exception i cannot explain.
     Could someone tell me what i'm doing wrong ??

     Here is the code sample, comments are following :

Code Sample :
----------------------------------

// this methode build a new DOM tree and use this one in a
// initialisation operation.
void myclass::AddSomthing(Params ...)
{
     // First, thanks to one of my data structure, i get back
     // the DOM_Document i'm working on and i use it to
     // create a new DOM_Element.
     DOM_Element elem;
     elem = 
personalDataStructure.getUserData().getOwnerDocument().createElement(DOMString("A_Tag"));

     // Once this Element is create, i build a DOM_TreeWalker
     // based on this node; this way i can re-use another of my
     // functions that use a DOM_TreeWalker as parameter.
     DOM_TreeWalker dtw;
     dtw = msg.getOwnerDocument().createTreeWalker(msg, ALL_EXCEPT_TEXT , NULL, false);

     // I add a few attributes to this element.
     msg.setAttribute( DOMString("Att1") , DOMString("AttVal1") );
     msg.setAttribute( DOMString("Att2") , DOMString("AttVal2") );
     ...

     // finaly i call the function that i want to re-use with the
     // DOM_TreeWalker passed as argument.
     testAndAdd(dtw);
}




// This methode performe some test on a DOM tree throught
// the DOM_TreeWalker passed in the Args List. Then it add
// the tree to another DOM_Element if this tree has no parents
void myclass::testAndAdd(DOM_TreeWalker &dtw)
{
     // first i get back the DOM_Element lying behind the
     // DOM_TreeWalker.
     DOM_Element elem = (DOM_Element &) dtw.getCurrentNode();

     // then i performe a few test on it
     if( elem.getAttribute ...... )
     .....

     // finally if this element node have no parents, i append
     // it to another DOM_Element.
     bool orphan = (elem.getParentNode() == NULL);
     if( orphan )
     {
          // before performing the "appendChild", i test
          // the compatibility.
          if( elem.getOwnerDocument() == futurFather.getOwnerDocument() )
               futurFather.appendChild(elem);   /* THE EXCPETION IS THROWN HERE */
          else
          {
          // a personal exception is thrown if there is
          // no compatibility
               throw MyException();
               exit(0);
          }
     }
}

----------------------------------

     The exception i'm catching is of type DOM_DOMException
     with an error code of 3. This one is thrown when execution flow
     reach the "futurFather.appendChild(elem);" line after a call to
     my methode AddSomething.

     The place where this exception is thrown is indicate in the code
     sample.

     This mean according to the Documentation of the DOM_Node::appendChild
     methode that i've tryed to :

          - either insert a node of the wrong type (which is not the case).

          - or to append one of his ancestor to the father node. this is
            impossible because the node i want to insert have been
            build on the fly during the call of "AddSomthing".

     So if you have an advice or an idea of what i'm missing, it will be of
     a great help for me.

Thanks.

benoit lefevre.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to