Commits

Anonymous committed 5b64eb7

Modified Files:
LibXML.xs
[fix] getOwnerDocument returns always the document

Comments (0)

Files changed (1)

             }
 
             RETVAL = nodeToSv((xmlNodePtr)real_dom);
+            real_dom->_private = RETVAL;
             setSvNodeExtra(RETVAL,RETVAL);
         }        
         LibXML_cleanup_callbacks();
                 xmlXIncludeProcess(real_dom);
 
             RETVAL = nodeToSv((xmlNodePtr)real_dom);
+            real_dom->_private = RETVAL;
             setSvNodeExtra(RETVAL,RETVAL);
         }
         LibXML_cleanup_callbacks();
             }
 
             RETVAL = nodeToSv((xmlNodePtr)real_dom);
+            real_dom->_private = RETVAL;
             setSvNodeExtra(RETVAL,RETVAL);
         }
         LibXML_cleanup_callbacks();
             real_dom->URL = xmlStrdup((const xmlChar*)SvPV(newURI, n_a));
             SvREFCNT_dec(newURI);
             RETVAL = nodeToSv((xmlNodePtr)real_dom);
+            real_dom->_private = RETVAL;
             setSvNodeExtra(RETVAL,RETVAL);
         }
     OUTPUT:
             real_dom->URL = xmlStrdup((const xmlChar*)SvPV(newURI, n_a));
             SvREFCNT_dec(newURI);
             RETVAL = nodeToSv((xmlNodePtr)real_dom);
+            real_dom->_private = RETVAL;
             setSvNodeExtra(RETVAL,RETVAL);
         }
     OUTPUT:
         }
         else {
             RETVAL = nodeToSv( (xmlNodePtr)real_dom ); 
+            real_dom->_private = RETVAL;
             setSvNodeExtra(RETVAL,RETVAL);
         }
     OUTPUT:
     CODE:
         real_dom = domCreateDocument( version, encoding ); 
         RETVAL = nodeToSv((xmlNodePtr)real_dom);
+        real_dom->_private = RETVAL;
         setSvNodeExtra(RETVAL,RETVAL);
     OUTPUT:
         RETVAL
             if ( newNode != NULL ) {        
                 newNode->doc = real_dom;
                 domAppendChild( docfrag, newNode );
-                # warn( newNode->name );
+                xs_warn( newNode->name );
                 RETVAL = nodeToSv(newNode);
                 setSvNodeExtra(RETVAL,docfrag_sv);
             }
             else {
+                xs_warn( "no node created!" );
                 XSRETURN_UNDEF;
             }
         }
     PREINIT:
         xmlNodePtr pNode, nNode, oNode;
     CODE:
+        if ( new != NULL
+             && new != &PL_sv_undef
+             && ref != NULL
+             && ref != &PL_sv_undef ) {
         pNode = getSvNode(self);
         nNode = getSvNode(new);
         oNode = getSvNode(ref);
              && domInsertBefore( pNode, nNode, oNode ) != NULL ) {
             fix_proxy_extra(new,getSvNodeExtra(self));
         }
-
+        }
 
 void
 insertAfter( self, new, ref )
     PREINIT:
         xmlNodePtr pNode, nNode, oNode;
     CODE:
+        if ( new != NULL
+             && new != &PL_sv_undef
+             && ref != NULL
+             && ref != &PL_sv_undef ) {
+            
         pNode = getSvNode(self);
         nNode = getSvNode(new);
         oNode = getSvNode(ref);
              && domInsertAfter( pNode, nNode, oNode ) != NULL ) {
             fix_proxy_extra(new,getSvNodeExtra(self));
         }
+        }
 
 SV*
 getOwnerDocument( elem )
         if( self != NULL
             && self->doc != NULL
             && getSvNodeExtra(elem) != NULL ){
-            RETVAL = getSvNodeExtra(elem);
+            RETVAL = (SV*)self->doc->_private;
             SvREFCNT_inc( RETVAL );
         }
         else {