libxml-ruby 2.9.0-x64-mingw32 → 3.0.0-x64-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/HISTORY +811 -790
- data/LICENSE +20 -20
- data/MANIFEST +166 -166
- data/README.rdoc +188 -184
- data/Rakefile +1 -1
- data/ext/libxml/libxml.c +80 -80
- data/ext/libxml/ruby_libxml.h +75 -75
- data/ext/libxml/ruby_xml.c +0 -84
- data/ext/libxml/ruby_xml.h +0 -10
- data/ext/libxml/ruby_xml_attr.h +12 -12
- data/ext/libxml/ruby_xml_attr_decl.c +153 -153
- data/ext/libxml/ruby_xml_attr_decl.h +11 -11
- data/ext/libxml/ruby_xml_attributes.c +275 -275
- data/ext/libxml/ruby_xml_attributes.h +15 -15
- data/ext/libxml/ruby_xml_document.c +21 -27
- data/ext/libxml/ruby_xml_document.h +11 -11
- data/ext/libxml/ruby_xml_dtd.c +2 -13
- data/ext/libxml/ruby_xml_dtd.h +9 -9
- data/ext/libxml/ruby_xml_error.c +996 -996
- data/ext/libxml/ruby_xml_error.h +12 -12
- data/ext/libxml/ruby_xml_html_parser.c +89 -92
- data/ext/libxml/ruby_xml_html_parser.h +10 -10
- data/ext/libxml/ruby_xml_html_parser_context.h +10 -10
- data/ext/libxml/ruby_xml_html_parser_options.c +46 -46
- data/ext/libxml/ruby_xml_html_parser_options.h +10 -10
- data/ext/libxml/ruby_xml_input_cbg.h +20 -20
- data/ext/libxml/ruby_xml_io.c +0 -1
- data/ext/libxml/ruby_xml_io.h +10 -10
- data/ext/libxml/ruby_xml_namespace.c +153 -153
- data/ext/libxml/ruby_xml_namespace.h +10 -10
- data/ext/libxml/ruby_xml_namespaces.c +293 -293
- data/ext/libxml/ruby_xml_namespaces.h +9 -9
- data/ext/libxml/ruby_xml_node.c +100 -143
- data/ext/libxml/ruby_xml_node.h +13 -11
- data/ext/libxml/ruby_xml_parser.c +91 -94
- data/ext/libxml/ruby_xml_parser.h +12 -12
- data/ext/libxml/ruby_xml_parser_context.h +10 -10
- data/ext/libxml/ruby_xml_parser_options.c +66 -66
- data/ext/libxml/ruby_xml_parser_options.h +12 -12
- data/ext/libxml/ruby_xml_reader.c +45 -37
- data/ext/libxml/ruby_xml_reader.h +17 -17
- data/ext/libxml/ruby_xml_relaxng.h +10 -10
- data/ext/libxml/ruby_xml_sax2_handler.c +3 -3
- data/ext/libxml/ruby_xml_sax2_handler.h +10 -10
- data/ext/libxml/ruby_xml_sax_parser.c +116 -120
- data/ext/libxml/ruby_xml_sax_parser.h +10 -10
- data/ext/libxml/ruby_xml_schema.h +809 -809
- data/ext/libxml/ruby_xml_schema_attribute.c +109 -109
- data/ext/libxml/ruby_xml_schema_attribute.h +15 -15
- data/ext/libxml/ruby_xml_schema_element.c +94 -94
- data/ext/libxml/ruby_xml_schema_element.h +14 -14
- data/ext/libxml/ruby_xml_schema_facet.c +52 -52
- data/ext/libxml/ruby_xml_schema_facet.h +13 -13
- data/ext/libxml/ruby_xml_schema_type.c +259 -259
- data/ext/libxml/ruby_xml_schema_type.h +9 -9
- data/ext/libxml/ruby_xml_version.h +9 -9
- data/ext/libxml/ruby_xml_writer.c +1136 -1136
- data/ext/libxml/ruby_xml_writer.h +10 -10
- data/ext/libxml/ruby_xml_xinclude.c +16 -16
- data/ext/libxml/ruby_xml_xinclude.h +11 -11
- data/ext/libxml/ruby_xml_xpath.c +42 -36
- data/ext/libxml/ruby_xml_xpath.h +13 -13
- data/ext/libxml/ruby_xml_xpath_context.c +1 -1
- data/ext/libxml/ruby_xml_xpath_context.h +9 -9
- data/ext/libxml/ruby_xml_xpath_expression.c +81 -81
- data/ext/libxml/ruby_xml_xpath_expression.h +10 -10
- data/ext/libxml/ruby_xml_xpath_object.c +5 -2
- data/ext/libxml/ruby_xml_xpath_object.h +17 -17
- data/ext/libxml/ruby_xml_xpointer.c +99 -99
- data/ext/libxml/ruby_xml_xpointer.h +11 -11
- data/ext/vc/libxml_ruby.sln +17 -15
- data/lib/2.4/libxml_ruby.so +0 -0
- data/lib/libs/libxml2-2.dll +0 -0
- data/lib/libs/zlib1.dll +0 -0
- data/lib/libxml.rb +1 -6
- data/lib/libxml/node.rb +2 -78
- data/lib/libxml/parser.rb +0 -266
- data/lib/libxml/sax_parser.rb +0 -17
- data/lib/libxml/schema.rb +66 -66
- data/lib/libxml/schema/attribute.rb +19 -19
- data/lib/libxml/schema/element.rb +27 -27
- data/lib/libxml/schema/type.rb +29 -29
- data/script/benchmark/depixelate +634 -634
- data/script/benchmark/hamlet.xml +9054 -9054
- data/script/benchmark/parsecount +170 -170
- data/script/benchmark/throughput +41 -41
- data/script/test +6 -6
- data/test/c14n/given/example-1.xml +14 -14
- data/test/c14n/given/example-2.xml +11 -11
- data/test/c14n/given/example-3.xml +18 -18
- data/test/c14n/given/example-4.xml +9 -9
- data/test/c14n/given/example-5.xml +12 -12
- data/test/c14n/given/example-6.xml +2 -2
- data/test/c14n/given/example-7.xml +11 -11
- data/test/c14n/given/example-8.xml +11 -11
- data/test/c14n/given/example-8.xpath +9 -9
- data/test/c14n/result/1-1-without-comments/example-1 +3 -3
- data/test/c14n/result/1-1-without-comments/example-2 +10 -10
- data/test/c14n/result/1-1-without-comments/example-3 +13 -13
- data/test/c14n/result/1-1-without-comments/example-4 +8 -8
- data/test/c14n/result/1-1-without-comments/example-5 +2 -2
- data/test/c14n/result/with-comments/example-1 +5 -5
- data/test/c14n/result/with-comments/example-2 +10 -10
- data/test/c14n/result/with-comments/example-3 +13 -13
- data/test/c14n/result/with-comments/example-4 +8 -8
- data/test/c14n/result/with-comments/example-5 +3 -3
- data/test/c14n/result/without-comments/example-1 +3 -3
- data/test/c14n/result/without-comments/example-2 +10 -10
- data/test/c14n/result/without-comments/example-3 +13 -13
- data/test/c14n/result/without-comments/example-4 +8 -8
- data/test/c14n/result/without-comments/example-5 +2 -2
- data/test/model/atom.xml +12 -12
- data/test/model/bands.iso-8859-1.xml +4 -4
- data/test/model/bands.utf-8.xml +4 -4
- data/test/model/bands.xml +4 -4
- data/test/model/books.xml +153 -153
- data/test/model/merge_bug_data.xml +58 -58
- data/test/model/ruby-lang.html +238 -238
- data/test/model/rubynet.xml +79 -79
- data/test/model/shiporder.rnc +28 -28
- data/test/model/shiporder.rng +86 -86
- data/test/model/shiporder.xml +22 -22
- data/test/model/shiporder.xsd +39 -39
- data/test/model/soap.xml +27 -27
- data/test/model/xinclude.xml +4 -4
- data/test/tc_attributes.rb +0 -6
- data/test/tc_error.rb +157 -158
- data/test/tc_node.rb +33 -17
- data/test/tc_node_edit.rb +0 -15
- data/test/tc_node_pi.rb +39 -39
- data/test/tc_parser.rb +0 -48
- data/test/tc_reader.rb +12 -53
- data/test/tc_writer.rb +447 -447
- data/test/tc_xpath.rb +1 -1
- data/test/test_helper.rb +2 -2
- metadata +4 -9
- data/ext/libxml/extconf.h +0 -4
- data/lib/2.3/libxml_ruby.so +0 -0
- data/lib/libxml/ns.rb +0 -22
- data/lib/libxml/properties.rb +0 -23
- data/lib/libxml/reader.rb +0 -29
- data/lib/libxml/xpath_object.rb +0 -16
| @@ -1,9 +1,9 @@ | |
| 1 | 
            -
            /* Please see the LICENSE file for copyright and distribution information */
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            #ifndef __RXML_NAMESPACES__
         | 
| 4 | 
            -
            #define __RXML_NAMESPACES__
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            extern VALUE cXMLNamespaces;
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            void rxml_init_namespaces(void);
         | 
| 9 | 
            -
            #endif
         | 
| 1 | 
            +
            /* Please see the LICENSE file for copyright and distribution information */
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            #ifndef __RXML_NAMESPACES__
         | 
| 4 | 
            +
            #define __RXML_NAMESPACES__
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            extern VALUE cXMLNamespaces;
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            void rxml_init_namespaces(void);
         | 
| 9 | 
            +
            #endif
         | 
    
        data/ext/libxml/ruby_xml_node.c
    CHANGED
    
    | @@ -17,89 +17,103 @@ VALUE cXMLNode; | |
| 17 17 |  | 
| 18 18 | 
             
            /* Memory management:
         | 
| 19 19 | 
             
             *
         | 
| 20 | 
            -
             * The bindings create a one-to-one mapping between  | 
| 21 | 
            -
             *  | 
| 22 | 
            -
             *  | 
| 23 | 
            -
             *
         | 
| 24 | 
            -
             *  | 
| 25 | 
            -
             *  | 
| 26 | 
            -
             *
         | 
| 27 | 
            -
             * | 
| 28 | 
            -
             * | 
| 29 | 
            -
             * | 
| 30 | 
            -
             * | 
| 31 | 
            -
             *
         | 
| 32 | 
            -
             *  | 
| 33 | 
            -
             *  | 
| 34 | 
            -
             *  | 
| 35 | 
            -
             *
         | 
| 36 | 
            -
             *  | 
| 37 | 
            -
             * | 
| 38 | 
            -
             *  | 
| 39 | 
            -
             * is  | 
| 40 | 
            -
             *  | 
| 20 | 
            +
             * The bindings create a one-to-one mapping between ruby objects and
         | 
| 21 | 
            +
             * libxml documents and libxml parent nodes (ie, nodes that do not
         | 
| 22 | 
            +
             * have a parent and do not belong to a document). In these cases,
         | 
| 23 | 
            +
             * the bindings manage the memory.  They do this by installing a free
         | 
| 24 | 
            +
             * function and storing a back pointer to the Ruby object from the xmlnode
         | 
| 25 | 
            +
             * using the _private member on libxml structures.  When the Ruby object
         | 
| 26 | 
            +
             * goes out of scope, the underlying libxml structure is freed.  Libxml
         | 
| 27 | 
            +
             * itself then frees all child node (recursively).
         | 
| 28 | 
            +
             *
         | 
| 29 | 
            +
             * For all other nodes (the vast majority), the bindings create temporary
         | 
| 30 | 
            +
             * Ruby objects that get freed once they go out of scope. Thus there can be
         | 
| 31 | 
            +
             * more than one ruby object pointing to the same xml node.  To mostly hide
         | 
| 32 | 
            +
             * this from programmers on the ruby side, the #eql? and #== methods are 
         | 
| 33 | 
            +
             * overriden to check if two ruby objects wrap the same xmlnode.  If they do,
         | 
| 34 | 
            +
             * then the methods return true.  During the mark phase, each of these temporary
         | 
| 35 | 
            +
             * objects marks its owning document, thereby keeping the Ruby document object
         | 
| 36 | 
            +
             * alive and thus the xmldoc tree.
         | 
| 37 | 
            +
             *
         | 
| 38 | 
            +
             * In the sweep phase of the garbage collector, or when a program ends, 
         | 
| 39 | 
            +
             * there is no order to how Ruby objects are freed. In fact, the ruby document
         | 
| 40 | 
            +
             * object is almost always freed before any ruby objects that wrap child nodes.
         | 
| 41 | 
            +
             * However, this is ok because those ruby objects do not have a free function
         | 
| 42 | 
            +
             * and are no longer in scope (since if they were the document would not be freed).
         | 
| 41 43 | 
             
             */
         | 
| 42 44 |  | 
| 43 | 
            -
            static void rxml_node_deregisterNode(xmlNodePtr xnode)
         | 
| 44 | 
            -
            {
         | 
| 45 | 
            -
              /* Has the node been wrapped and exposed to Ruby? */
         | 
| 46 | 
            -
              VALUE node = rxml_lookup_node(xnode);
         | 
| 47 | 
            -
              if (node == Qnil)
         | 
| 48 | 
            -
                  return;
         | 
| 49 | 
            -
             | 
| 50 | 
            -
              /* Node was wrapped. Disassociate the ruby object from the xml node
         | 
| 51 | 
            -
                 and turn off the free function so Ruby will not call it when the
         | 
| 52 | 
            -
                 wrapping object is itself freed. Note we still MUST include 
         | 
| 53 | 
            -
                 the mark function.  Unsetting it breaks the Ruby GC. */
         | 
| 54 | 
            -
               RDATA(node)->dfree = NULL;
         | 
| 55 | 
            -
               RDATA(node)->data = NULL;
         | 
| 56 | 
            -
             | 
| 57 | 
            -
              // Remove the hashtable entry
         | 
| 58 | 
            -
              rxml_unregister_node(xnode);
         | 
| 59 | 
            -
            }
         | 
| 60 | 
            -
             | 
| 61 45 | 
             
            static void rxml_node_free(xmlNodePtr xnode)
         | 
| 62 46 | 
             
            {
         | 
| 63 | 
            -
              /* The ruby object wrapping the xml object no longer exists | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
              /* Ruby is responsible for freeing this node if it does not
         | 
| 67 | 
            -
                 have a parent and is not owned by a document.  Note a corner
         | 
| 68 | 
            -
                 case here - calling node2 = doc.import(node1) will cause node2
         | 
| 69 | 
            -
                 to not have a parent but to have a document. */
         | 
| 47 | 
            +
              /* The ruby object wrapping the xml object no longer exists and this
         | 
| 48 | 
            +
                 is a standalone node without a document or parent so ruby is 
         | 
| 49 | 
            +
                 responsible for freeing the underlying node.*/
         | 
| 70 50 | 
             
              if (xnode->doc == NULL && xnode->parent == NULL)
         | 
| 71 51 | 
             
              {
         | 
| 52 | 
            +
                // Remove the back linkage from libxml to Ruby
         | 
| 53 | 
            +
                xnode->_private = NULL;
         | 
| 72 54 | 
             
                xmlFreeNode(xnode);
         | 
| 73 55 | 
             
              }
         | 
| 74 56 | 
             
            }
         | 
| 75 57 |  | 
| 76 | 
            -
             | 
| 58 | 
            +
            void rxml_node_manage(xmlNodePtr xnode, VALUE node)
         | 
| 77 59 | 
             
            {
         | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 60 | 
            +
              RDATA(node)->dfree = rxml_node_free;
         | 
| 61 | 
            +
              xnode->_private = (void*)node;
         | 
| 62 | 
            +
            }
         | 
| 80 63 |  | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
               | 
| 85 | 
            -
             | 
| 64 | 
            +
            void rxml_node_unmanage(xmlNodePtr xnode, VALUE node)
         | 
| 65 | 
            +
            {
         | 
| 66 | 
            +
              RDATA(node)->dfree = NULL;
         | 
| 67 | 
            +
              xnode->_private = NULL;
         | 
| 68 | 
            +
            }
         | 
| 86 69 |  | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 70 | 
            +
            xmlNodePtr rxml_node_root(xmlNodePtr xnode)
         | 
| 71 | 
            +
            {
         | 
| 72 | 
            +
              xmlNodePtr current = xnode;
         | 
| 90 73 |  | 
| 91 | 
            -
               | 
| 92 | 
            -
               | 
| 93 | 
            -
             | 
| 74 | 
            +
              while (current->parent)
         | 
| 75 | 
            +
              {
         | 
| 76 | 
            +
                current = current->parent;
         | 
| 77 | 
            +
              }
         | 
| 78 | 
            +
             | 
| 79 | 
            +
              return current;
         | 
| 80 | 
            +
            }
         | 
| 81 | 
            +
             | 
| 82 | 
            +
            void rxml_node_mark(xmlNodePtr xnode)
         | 
| 83 | 
            +
            {
         | 
| 84 | 
            +
               if (xnode->doc)
         | 
| 85 | 
            +
               {
         | 
| 86 | 
            +
                 VALUE doc = (VALUE)xnode->doc->_private;
         | 
| 87 | 
            +
                 rb_gc_mark(doc);
         | 
| 88 | 
            +
               }
         | 
| 89 | 
            +
               else if (xnode->parent)
         | 
| 90 | 
            +
               {
         | 
| 91 | 
            +
                 xmlNodePtr root = rxml_node_root(xnode);
         | 
| 92 | 
            +
                 if (root->_private)
         | 
| 93 | 
            +
                 {
         | 
| 94 | 
            +
                   VALUE node = (VALUE)root->_private;
         | 
| 95 | 
            +
                   rb_gc_mark(node);
         | 
| 96 | 
            +
                 }
         | 
| 97 | 
            +
               }
         | 
| 94 98 | 
             
            }
         | 
| 95 99 |  | 
| 96 100 | 
             
            VALUE rxml_node_wrap(xmlNodePtr xnode)
         | 
| 97 101 | 
             
            {
         | 
| 98 | 
            -
              VALUE result =  | 
| 102 | 
            +
              VALUE result = Qnil;
         | 
| 103 | 
            +
             | 
| 104 | 
            +
              // Is this node already wrapped?
         | 
| 105 | 
            +
              if (xnode->_private)
         | 
| 106 | 
            +
              {
         | 
| 107 | 
            +
                result = (VALUE)xnode->_private;
         | 
| 108 | 
            +
              }
         | 
| 109 | 
            +
              else
         | 
| 110 | 
            +
              {
         | 
| 111 | 
            +
                result = Data_Wrap_Struct(cXMLNode, rxml_node_mark, NULL, xnode);
         | 
| 112 | 
            +
              }
         | 
| 99 113 |  | 
| 100 | 
            -
              if ( | 
| 101 | 
            -
             | 
| 102 | 
            -
                 | 
| 114 | 
            +
              if (!xnode->doc && !xnode->parent)
         | 
| 115 | 
            +
              {
         | 
| 116 | 
            +
                rxml_node_manage(xnode, result);
         | 
| 103 117 | 
             
              }
         | 
| 104 118 | 
             
              return result;
         | 
| 105 119 | 
             
            }
         | 
| @@ -270,9 +284,11 @@ static VALUE rxml_node_initialize(int argc, VALUE *argv, VALUE self) | |
| 270 284 | 
             
              if (xnode == NULL)
         | 
| 271 285 | 
             
                rxml_raise(&xmlLastError);
         | 
| 272 286 |  | 
| 273 | 
            -
               | 
| 274 | 
            -
               | 
| 275 | 
            -
             | 
| 287 | 
            +
              // Link the ruby wrapper to the underlying libxml node
         | 
| 288 | 
            +
              RDATA(self)->data = xnode;
         | 
| 289 | 
            +
             | 
| 290 | 
            +
              // Ruby is in charge of managing this node's memory
         | 
| 291 | 
            +
              rxml_node_manage(xnode, self);
         | 
| 276 292 |  | 
| 277 293 | 
             
              if (!NIL_P(content))
         | 
| 278 294 | 
             
                rxml_node_content_set(self, content);
         | 
| @@ -306,9 +322,12 @@ static VALUE rxml_node_modify_dom(VALUE self, VALUE target, | |
| 306 322 | 
             
              if (xresult != xtarget)
         | 
| 307 323 | 
             
              {
         | 
| 308 324 | 
             
                RDATA(target)->data = xresult;
         | 
| 309 | 
            -
                rxml_register_node(xresult, target);
         | 
| 310 325 | 
             
              }
         | 
| 311 326 |  | 
| 327 | 
            +
              // Target now has a parent so ruby should no longer manage its memory
         | 
| 328 | 
            +
              rxml_node_unmanage(xresult, target);
         | 
| 329 | 
            +
              xtarget->_private = NULL;
         | 
| 330 | 
            +
             | 
| 312 331 | 
             
              return target;
         | 
| 313 332 | 
             
            }
         | 
| 314 333 |  | 
| @@ -402,35 +421,6 @@ static VALUE rxml_node_content_set(VALUE self, VALUE content) | |
| 402 421 | 
             
              return (Qtrue);
         | 
| 403 422 | 
             
            }
         | 
| 404 423 |  | 
| 405 | 
            -
            /*
         | 
| 406 | 
            -
             * call-seq:
         | 
| 407 | 
            -
             *    node.content_stripped -> "string"
         | 
| 408 | 
            -
             *
         | 
| 409 | 
            -
             * Obtain this node's stripped content.
         | 
| 410 | 
            -
             *
         | 
| 411 | 
            -
             * *Deprecated*: Stripped content can be obtained via the
         | 
| 412 | 
            -
             * +content+ method.
         | 
| 413 | 
            -
             */
         | 
| 414 | 
            -
            static VALUE rxml_node_content_stripped_get(VALUE self)
         | 
| 415 | 
            -
            {
         | 
| 416 | 
            -
              xmlNodePtr xnode;
         | 
| 417 | 
            -
              xmlChar* content;
         | 
| 418 | 
            -
              VALUE result = Qnil;
         | 
| 419 | 
            -
             | 
| 420 | 
            -
              xnode = rxml_get_xnode(self);
         | 
| 421 | 
            -
             | 
| 422 | 
            -
              if (!xnode->content)
         | 
| 423 | 
            -
                return result;
         | 
| 424 | 
            -
             | 
| 425 | 
            -
              content = xmlNodeGetContent(xnode);
         | 
| 426 | 
            -
              if (content)
         | 
| 427 | 
            -
              {
         | 
| 428 | 
            -
                result = rxml_new_cstr( content, NULL);
         | 
| 429 | 
            -
                xmlFree(content);
         | 
| 430 | 
            -
              }
         | 
| 431 | 
            -
              return (result);
         | 
| 432 | 
            -
            }
         | 
| 433 | 
            -
             | 
| 434 424 | 
             
            /*
         | 
| 435 425 | 
             
             * call-seq:
         | 
| 436 426 | 
             
             *    node.debug -> true|false
         | 
| @@ -540,7 +530,7 @@ static VALUE rxml_node_doc(VALUE self) | |
| 540 530 | 
             
              if (xdoc == NULL)
         | 
| 541 531 | 
             
                return (Qnil);
         | 
| 542 532 |  | 
| 543 | 
            -
              return  | 
| 533 | 
            +
              return (VALUE)xdoc->_private;
         | 
| 544 534 | 
             
            }
         | 
| 545 535 |  | 
| 546 536 | 
             
            /*
         | 
| @@ -684,10 +674,10 @@ static VALUE rxml_node_empty_q(VALUE self) | |
| 684 674 | 
             
             *    node.eql?(other_node) => (true|false)
         | 
| 685 675 | 
             
             *
         | 
| 686 676 | 
             
             * Test equality between the two nodes. Two nodes are equal
         | 
| 687 | 
            -
             * if they are the same node | 
| 677 | 
            +
             * if they are the same node.*/
         | 
| 688 678 | 
             
            static VALUE rxml_node_eql_q(VALUE self, VALUE other)
         | 
| 689 679 | 
             
            {
         | 
| 690 | 
            -
              if(self == other)
         | 
| 680 | 
            +
              if (self == other)
         | 
| 691 681 | 
             
              {
         | 
| 692 682 | 
             
                return Qtrue;
         | 
| 693 683 | 
             
              }
         | 
| @@ -697,15 +687,9 @@ static VALUE rxml_node_eql_q(VALUE self, VALUE other) | |
| 697 687 | 
             
              }
         | 
| 698 688 | 
             
              else
         | 
| 699 689 | 
             
              {
         | 
| 700 | 
            -
                 | 
| 701 | 
            -
                 | 
| 702 | 
            -
             | 
| 703 | 
            -
                if (rb_obj_is_kind_of(other, cXMLNode) == Qfalse)
         | 
| 704 | 
            -
                  rb_raise(rb_eTypeError, "Nodes can only be compared against other nodes");
         | 
| 705 | 
            -
             | 
| 706 | 
            -
                self_xml = rxml_node_to_s(0, NULL, self);
         | 
| 707 | 
            -
                other_xml = rxml_node_to_s(0, NULL, other);
         | 
| 708 | 
            -
                return(rb_funcall(self_xml, rb_intern("=="), 1, other_xml));
         | 
| 690 | 
            +
                xmlNodePtr xnode = rxml_get_xnode(self);
         | 
| 691 | 
            +
                xmlNodePtr xnode_other = rxml_get_xnode(other);
         | 
| 692 | 
            +
                return xnode == xnode_other ? Qtrue : Qfalse;
         | 
| 709 693 | 
             
              }
         | 
| 710 694 | 
             
            }
         | 
| 711 695 |  | 
| @@ -1125,35 +1109,15 @@ static VALUE rxml_node_property_set(VALUE self, VALUE name, VALUE value) | |
| 1125 1109 |  | 
| 1126 1110 | 
             
            static VALUE rxml_node_remove_ex(VALUE self)
         | 
| 1127 1111 | 
             
            {
         | 
| 1128 | 
            -
              xmlNodePtr xnode | 
| 1129 | 
            -
             | 
| 1130 | 
            -
             | 
| 1131 | 
            -
              /* First unlink the node from its parent. */
         | 
| 1112 | 
            +
              xmlNodePtr xnode = rxml_get_xnode(self);
         | 
| 1113 | 
            +
             
         | 
| 1114 | 
            +
              // Now unlink the node from its parent
         | 
| 1132 1115 | 
             
              xmlUnlinkNode(xnode);
         | 
| 1133 1116 |  | 
| 1134 | 
            -
               | 
| 1135 | 
            -
             | 
| 1136 | 
            -
             | 
| 1137 | 
            -
             | 
| 1138 | 
            -
                 namespaces, etc.  For a node to live on its own, it
         | 
| 1139 | 
            -
                 needs to get its own copies of this information.*/
         | 
| 1140 | 
            -
              xresult = xmlDocCopyNode(xnode, NULL, 1);
         | 
| 1141 | 
            -
             | 
| 1142 | 
            -
              /* This ruby node object no longer points at the node.*/
         | 
| 1143 | 
            -
              rxml_unregister_node(xnode);
         | 
| 1144 | 
            -
              RDATA(self)->data = NULL;
         | 
| 1145 | 
            -
             | 
| 1146 | 
            -
              /* Now free the original node.  This will call the deregister node
         | 
| 1147 | 
            -
                callback which would reset the mark and free function except for
         | 
| 1148 | 
            -
            	the fact we already removed it from the private hashtable above */
         | 
| 1149 | 
            -
              xmlFreeNode(xnode);
         | 
| 1150 | 
            -
             | 
| 1151 | 
            -
              /* Now wrap the new node */
         | 
| 1152 | 
            -
              RDATA(self)->data = xresult;
         | 
| 1153 | 
            -
              rxml_register_node(xresult, self);
         | 
| 1154 | 
            -
             | 
| 1155 | 
            -
              /* Now return the removed node so the user can
         | 
| 1156 | 
            -
                 do something with it.*/
         | 
| 1117 | 
            +
              // Ruby now manages this node
         | 
| 1118 | 
            +
              rxml_node_manage(xnode, self);
         | 
| 1119 | 
            +
             | 
| 1120 | 
            +
              // Now return the removed node so the user can do something with it
         | 
| 1157 1121 | 
             
              return self;
         | 
| 1158 1122 | 
             
            }
         | 
| 1159 1123 |  | 
| @@ -1335,12 +1299,6 @@ static VALUE rxml_node_copy(VALUE self, VALUE deep) | |
| 1335 1299 |  | 
| 1336 1300 | 
             
            void rxml_init_node(void)
         | 
| 1337 1301 | 
             
            {
         | 
| 1338 | 
            -
              /* Register callback for main thread */
         | 
| 1339 | 
            -
              xmlDeregisterNodeDefault(rxml_node_deregisterNode);
         | 
| 1340 | 
            -
             | 
| 1341 | 
            -
              /* Register callback for all other threads */
         | 
| 1342 | 
            -
              xmlThrDefDeregisterNodeDefault(rxml_node_deregisterNode);
         | 
| 1343 | 
            -
             | 
| 1344 1302 | 
             
              cXMLNode = rb_define_class_under(mXML, "Node", rb_cObject);
         | 
| 1345 1303 |  | 
| 1346 1304 | 
             
              rb_define_const(cXMLNode, "SPACE_DEFAULT", INT2NUM(0));
         | 
| @@ -1419,7 +1377,6 @@ void rxml_init_node(void) | |
| 1419 1377 | 
             
              rb_define_method(cXMLNode, "copy", rxml_node_copy, 1);
         | 
| 1420 1378 | 
             
              rb_define_method(cXMLNode, "content", rxml_node_content_get, 0);
         | 
| 1421 1379 | 
             
              rb_define_method(cXMLNode, "content=", rxml_node_content_set, 1);
         | 
| 1422 | 
            -
              rb_define_method(cXMLNode, "content_stripped", rxml_node_content_stripped_get, 0);
         | 
| 1423 1380 | 
             
              rb_define_method(cXMLNode, "debug", rxml_node_debug, 0);
         | 
| 1424 1381 | 
             
              rb_define_method(cXMLNode, "doc", rxml_node_doc, 0);
         | 
| 1425 1382 | 
             
              rb_define_method(cXMLNode, "empty?", rxml_node_empty_q, 0);
         | 
    
        data/ext/libxml/ruby_xml_node.h
    CHANGED
    
    | @@ -1,11 +1,13 @@ | |
| 1 | 
            -
            /* Please see the LICENSE file for copyright and distribution information */
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            #ifndef __RXML_NODE__
         | 
| 4 | 
            -
            #define __RXML_NODE__
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            extern VALUE cXMLNode;
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            void rxml_init_node(void);
         | 
| 9 | 
            -
            void rxml_node_mark(xmlNodePtr xnode);
         | 
| 10 | 
            -
            VALUE rxml_node_wrap(xmlNodePtr xnode);
         | 
| 11 | 
            -
             | 
| 1 | 
            +
            /* Please see the LICENSE file for copyright and distribution information */
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            #ifndef __RXML_NODE__
         | 
| 4 | 
            +
            #define __RXML_NODE__
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            extern VALUE cXMLNode;
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            void rxml_init_node(void);
         | 
| 9 | 
            +
            void rxml_node_mark(xmlNodePtr xnode);
         | 
| 10 | 
            +
            VALUE rxml_node_wrap(xmlNodePtr xnode);
         | 
| 11 | 
            +
            void rxml_node_manage(xmlNodePtr xnode, VALUE node);
         | 
| 12 | 
            +
            void rxml_node_unmanage(xmlNodePtr xnode, VALUE node);
         | 
| 13 | 
            +
            #endif
         | 
| @@ -1,94 +1,91 @@ | |
| 1 | 
            -
            /* Please see the LICENSE file for copyright and distribution information */
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            #include <stdarg.h>
         | 
| 4 | 
            -
            #include "ruby_libxml.h"
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            /*
         | 
| 7 | 
            -
             * Document-class: LibXML::XML::Parser
         | 
| 8 | 
            -
             *
         | 
| 9 | 
            -
             * The XML::Parser provides a tree based API for processing
         | 
| 10 | 
            -
             * xml documents, in contract to XML::Reader's stream
         | 
| 11 | 
            -
             * based api and XML::SaxParser callback based API.
         | 
| 12 | 
            -
             *
         | 
| 13 | 
            -
             * As a result, parsing a document creates an in-memory document object
         | 
| 14 | 
            -
             * that consist of any number of XML::Node instances.  This is simple
         | 
| 15 | 
            -
             * and powerful model, but has the major limitation that the size of
         | 
| 16 | 
            -
             * the document that can be processed is limited by the amount of
         | 
| 17 | 
            -
             * memory available.  In such cases, it is better to use the XML::Reader.
         | 
| 18 | 
            -
             *
         | 
| 19 | 
            -
             * Using the parser is simple:
         | 
| 20 | 
            -
             *
         | 
| 21 | 
            -
             *   parser = XML::Parser.file('my_file')
         | 
| 22 | 
            -
             *   doc = parser.parse
         | 
| 23 | 
            -
             *
         | 
| 24 | 
            -
             * You can also parse documents (see XML::Parser.document), 
         | 
| 25 | 
            -
             * strings (see XML::Parser.string) and io objects (see
         | 
| 26 | 
            -
             * XML::Parser.io).
         | 
| 27 | 
            -
             */
         | 
| 28 | 
            -
             | 
| 29 | 
            -
            VALUE cXMLParser;
         | 
| 30 | 
            -
            static ID CONTEXT_ATTR;
         | 
| 31 | 
            -
             | 
| 32 | 
            -
            /*
         | 
| 33 | 
            -
             * call-seq:
         | 
| 34 | 
            -
             *    parser.initialize(context) -> XML::Parser
         | 
| 35 | 
            -
             *
         | 
| 36 | 
            -
             * Creates a new XML::Parser from the specified 
         | 
| 37 | 
            -
             * XML::Parser::Context.
         | 
| 38 | 
            -
             */
         | 
| 39 | 
            -
            static VALUE rxml_parser_initialize(int argc, VALUE *argv, VALUE self)
         | 
| 40 | 
            -
            {
         | 
| 41 | 
            -
              VALUE context = Qnil;
         | 
| 42 | 
            -
             | 
| 43 | 
            -
              rb_scan_args(argc, argv, "01", &context);
         | 
| 44 | 
            -
             | 
| 45 | 
            -
              if (context == Qnil)
         | 
| 46 | 
            -
              {
         | 
| 47 | 
            -
                 | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
               | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             *  | 
| 57 | 
            -
             * | 
| 58 | 
            -
             *
         | 
| 59 | 
            -
             *  | 
| 60 | 
            -
             *  | 
| 61 | 
            -
              | 
| 62 | 
            -
              | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
               | 
| 66 | 
            -
               | 
| 67 | 
            -
              
         | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
               | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
               | 
| 85 | 
            -
             | 
| 86 | 
            -
               | 
| 87 | 
            -
             | 
| 88 | 
            -
               | 
| 89 | 
            -
               | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
              rb_define_method(cXMLParser, "initialize", rxml_parser_initialize, -1);
         | 
| 93 | 
            -
              rb_define_method(cXMLParser, "parse", rxml_parser_parse, 0);
         | 
| 94 | 
            -
            }
         | 
| 1 | 
            +
            /* Please see the LICENSE file for copyright and distribution information */
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            #include <stdarg.h>
         | 
| 4 | 
            +
            #include "ruby_libxml.h"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            /*
         | 
| 7 | 
            +
             * Document-class: LibXML::XML::Parser
         | 
| 8 | 
            +
             *
         | 
| 9 | 
            +
             * The XML::Parser provides a tree based API for processing
         | 
| 10 | 
            +
             * xml documents, in contract to XML::Reader's stream
         | 
| 11 | 
            +
             * based api and XML::SaxParser callback based API.
         | 
| 12 | 
            +
             *
         | 
| 13 | 
            +
             * As a result, parsing a document creates an in-memory document object
         | 
| 14 | 
            +
             * that consist of any number of XML::Node instances.  This is simple
         | 
| 15 | 
            +
             * and powerful model, but has the major limitation that the size of
         | 
| 16 | 
            +
             * the document that can be processed is limited by the amount of
         | 
| 17 | 
            +
             * memory available.  In such cases, it is better to use the XML::Reader.
         | 
| 18 | 
            +
             *
         | 
| 19 | 
            +
             * Using the parser is simple:
         | 
| 20 | 
            +
             *
         | 
| 21 | 
            +
             *   parser = XML::Parser.file('my_file')
         | 
| 22 | 
            +
             *   doc = parser.parse
         | 
| 23 | 
            +
             *
         | 
| 24 | 
            +
             * You can also parse documents (see XML::Parser.document), 
         | 
| 25 | 
            +
             * strings (see XML::Parser.string) and io objects (see
         | 
| 26 | 
            +
             * XML::Parser.io).
         | 
| 27 | 
            +
             */
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            VALUE cXMLParser;
         | 
| 30 | 
            +
            static ID CONTEXT_ATTR;
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            /*
         | 
| 33 | 
            +
             * call-seq:
         | 
| 34 | 
            +
             *    parser.initialize(context) -> XML::Parser
         | 
| 35 | 
            +
             *
         | 
| 36 | 
            +
             * Creates a new XML::Parser from the specified 
         | 
| 37 | 
            +
             * XML::Parser::Context.
         | 
| 38 | 
            +
             */
         | 
| 39 | 
            +
            static VALUE rxml_parser_initialize(int argc, VALUE *argv, VALUE self)
         | 
| 40 | 
            +
            {
         | 
| 41 | 
            +
              VALUE context = Qnil;
         | 
| 42 | 
            +
             | 
| 43 | 
            +
              rb_scan_args(argc, argv, "01", &context);
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              if (context == Qnil)
         | 
| 46 | 
            +
              {
         | 
| 47 | 
            +
                rb_raise(rb_eArgError, "An instance of a XML::Parser::Context must be passed to XML::Parser.new");
         | 
| 48 | 
            +
              }
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              rb_ivar_set(self, CONTEXT_ATTR, context);
         | 
| 51 | 
            +
              return self;
         | 
| 52 | 
            +
            }
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            /*
         | 
| 55 | 
            +
             * call-seq:
         | 
| 56 | 
            +
             *    parser.parse -> XML::Document
         | 
| 57 | 
            +
             *
         | 
| 58 | 
            +
             * Parse the input XML and create an XML::Document with
         | 
| 59 | 
            +
             * it's content. If an error occurs, XML::Parser::ParseError
         | 
| 60 | 
            +
             * is thrown.
         | 
| 61 | 
            +
             */
         | 
| 62 | 
            +
            static VALUE rxml_parser_parse(VALUE self)
         | 
| 63 | 
            +
            {
         | 
| 64 | 
            +
              xmlParserCtxtPtr ctxt;
         | 
| 65 | 
            +
              VALUE context = rb_ivar_get(self, CONTEXT_ATTR);
         | 
| 66 | 
            +
              
         | 
| 67 | 
            +
              Data_Get_Struct(context, xmlParserCtxt, ctxt);
         | 
| 68 | 
            +
             | 
| 69 | 
            +
              if ((xmlParseDocument(ctxt) == -1 || !ctxt->wellFormed) && ! ctxt->recovery)
         | 
| 70 | 
            +
              {
         | 
| 71 | 
            +
                rxml_raise(&ctxt->lastError);
         | 
| 72 | 
            +
              }
         | 
| 73 | 
            +
             | 
| 74 | 
            +
              rb_funcall(context, rb_intern("close"), 0);
         | 
| 75 | 
            +
             | 
| 76 | 
            +
              return rxml_document_wrap(ctxt->myDoc);
         | 
| 77 | 
            +
            }
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            void rxml_init_parser(void)
         | 
| 80 | 
            +
            {
         | 
| 81 | 
            +
              cXMLParser = rb_define_class_under(mXML, "Parser", rb_cObject);
         | 
| 82 | 
            +
             | 
| 83 | 
            +
              /* Atributes */
         | 
| 84 | 
            +
              CONTEXT_ATTR = rb_intern("@context");
         | 
| 85 | 
            +
              rb_define_attr(cXMLParser, "input", 1, 0);
         | 
| 86 | 
            +
              rb_define_attr(cXMLParser, "context", 1, 0);
         | 
| 87 | 
            +
             | 
| 88 | 
            +
              /* Instance Methods */
         | 
| 89 | 
            +
              rb_define_method(cXMLParser, "initialize", rxml_parser_initialize, -1);
         | 
| 90 | 
            +
              rb_define_method(cXMLParser, "parse", rxml_parser_parse, 0);
         | 
| 91 | 
            +
            }
         |